Cookbook / Coding assistants
OpenCode
Privatemode can be used as a model provider in OpenCode, an open-source agentic AI coding tool. This document explains how to set up OpenCode to use Privatemode.
Setting up the Privatemode proxy
Follow the API quickstart and choose Other languages to run the Privatemode proxy. Usually, it's advisable to enable prompt caching via --sharedPromptCache.
Configuring OpenCode
Create or edit the opencode.json in your project directory (or globally at ~/.config/opencode/opencode.json) to add Privatemode as a custom provider:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"privatemode": {
"npm": "@ai-sdk/openai-compatible",
"name": "Privatemode",
"options": {
"baseURL": "http://localhost:8080/v1",
"apiKey": "sk-privatemode"
},
"models": {
"kimi-latest": {
"name": "kimi-latest",
"family": "kimi",
"attachment": true,
"reasoning": true,
"tool_call": true,
"temperature": true,
"limit": {
"context": 262144,
"output": 32000
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
}
},
"glm-latest": {
"name": "glm-latest",
"family": "glm",
"attachment": false,
"reasoning": true,
"tool_call": true,
"temperature": true,
"limit": {
"context": 262144,
"output": 32000
},
"modalities": {
"input": [
"text"
],
"output": [
"text"
]
}
}
}
}
},
"model": "privatemode/kimi-latest"
}Providing an API key per user
To use a separate API key per user, set apiKey in your opencode.json to your own key or let OpenCode read the key from an environment variable:
"apiKey": "{env:PRIVATE_MODE_API_KEY}"OpenCode substitutes {env:...} at startup, so export PRIVATE_MODE_API_KEY="<your-api-key>" before starting OpenCode.
The proxy must be started without --apiKey, otherwise it uses the configured key instead.
Starting OpenCode with Privatemode
Once the configuration is in place, start OpenCode:
opencodeYou can also select the model explicitly:
opencode --model privatemode/kimi-latestPrivatemode offers privatemode/kimi-latest (recommended) or privatemode/glm-latest for coding with OpenCode.
You will be greeted with a screen like the following. You are now ready to "vibe code" confidentially 🥳