Cookbook / Coding assistants
Claude Code
Privatemode can be used as a model provider in Anthropic's Claude Code. This document explains how to set up Claude Code to use Privatemode.
Info
Make sure that you have at least v2.1.242 of Claude Code installed.
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 Claude Code
Add the following configuration to your ~/.claude/settings.json to use Privatemode in every project. To try it in a single project first, put it into .claude/settings.local.json in that project instead.
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:8080",
"ANTHROPIC_AUTH_TOKEN": "<your-api-key>",
"ANTHROPIC_DEFAULT_MODEL": "glm-latest",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1048576",
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1"
},
"availableModels": [
"glm-latest",
"glm-flash-latest"
],
"modelPicker": {
"options": [
{
"model": "glm-latest",
"label": "GLM"
},
{
"model": "glm-flash-latest",
"label": "GLM Flash"
}
],
"replaceBuiltInOptions": true
}
}Replace <your-api-key> with your Privatemode API key. Keep the default --api-key-fallback=never so the proxy forwards each user’s API key unchanged.
The settings do the following:
ANTHROPIC_BASE_URLpoints Claude Code at the proxy, andANTHROPIC_AUTH_TOKENauthenticates requests with your API key.ANTHROPIC_DEFAULT_MODELsets the default model.availableModelsrestricts Claude Code to the models Privatemode serves: it uses Anthropic models for sub-agents by default, and with this list in place, sub-agents fall back to the session's active model instead.modelPickerreplaces the built-in/modeloptions with the Privatemode models.CLAUDE_CODE_MAX_CONTEXT_TOKENSsets the model's maximum context length of 1M tokens. Claude Code doesn't recognize the model and would otherwise assume a 200k context window.CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICdisables optional telemetry and error reporting, andCLAUDE_CODE_ATTRIBUTION_HEADERomits Claude Code's attribution from the system prompt, which improves prompt-cache reuse.
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 set ANTHROPIC_AUTH_TOKEN in your settings file to placeholder:
"ANTHROPIC_AUTH_TOKEN": "placeholder"The proxy replaces the placeholder with its configured API key.
Starting Claude Code with Privatemode
Claude Code reads its environment at startup, so open a new session after changing the settings:
claudeTo use a different model for a single session, pass the --model flag, e.g.:
claude --model glm-flash-latestYou will be greeted with a screen like the following. You are now ready to "vibe code" confidentially 🥳
Reverting the setup
Remove the entries above from your settings file and stop the proxy. Claude Code then uses its default provider again.