Cookbook / Coding assistants
OpenCode
Privatemode can be used as a model provider in OpenCode, an open-source agentic AI coding tool. Privatemode is registered as the privatemode-ai provider on models.dev, OpenCode's provider catalog, so the endpoint and the available models are already known to OpenCode. 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. Check that the proxy is up with curl http://localhost:8080/readyz.
Configuring OpenCode
OpenCode enables a provider once it finds a credential for it. Export your API key and refresh the provider catalog so that OpenCode lists the models Privatemode currently serves:
export PRIVATEMODE_API_KEY="<your-api-key>"
opencode models --refresh privatemode-aiKeep the default --api-key-fallback=never so the proxy forwards each user’s API key unchanged.
Set the default model and API key in the opencode.json in your project directory (or globally at ~/.config/opencode/opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"model": "privatemode-ai/glm-latest",
"provider": {
"privatemode-ai": {
"options": {
"apiKey": "{env:PRIVATEMODE_API_KEY}"
}
}
}
}Privatemode offers privatemode-ai/glm-latest and privatemode-ai/glm-flash-latest for coding with OpenCode. Use one of the models listed by the previous step.
Using a different proxy address
The provider expects the proxy at http://localhost:8080/v1. If your proxy runs elsewhere, override the base URL in opencode.json:
"provider": {
"privatemode-ai": {
"options": {
"baseURL": "http://<proxy-host>:8080/v1",
"apiKey": "{env:PRIVATEMODE_API_KEY}"
}
}
}Using API-key fallback with a placeholder
To use the proxy's configured API key instead of providing an API key per user, start the proxy with --api-key-fallback=if-placeholder and export a placeholder:
export PRIVATEMODE_API_KEY=placeholderThe proxy then replaces the placeholder with its configured API key.
Starting OpenCode with Privatemode
Once the configuration is in place, start OpenCode:
opencodeYou can also select the model explicitly, e.g.:
opencode --model privatemode-ai/glm-flash-latestYou will be greeted with a screen like the following. You are now ready to "vibe code" confidentially 🥳