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.85 of Claude Code installed.
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 Claude Code
Add the following environment variables to your ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_BASE_URL": "http://localhost:8080",
"ANTHROPIC_AUTH_TOKEN": "sk-privatemode",
"CLAUDE_CODE_SUBAGENT_MODEL": "kimi-latest",
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144"
}
}CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC disables optional telemetry and error reporting, and CLAUDE_CODE_ATTRIBUTION_HEADER omits Claude Code's attribution from the system prompt, which improves prompt-cache reuse. Claude Code may not recognize the configured model and would then assume a 200k context window, so set CLAUDE_CODE_MAX_CONTEXT_TOKENS to the model's maximum context length.
If Claude Code asks you to sign-in on first run, set the following entry in your ~/.claude.json, which is different from ~/.claude/settings.json:
{
// ...
"hasCompletedOnboarding": true
}If you have used Claude before, ~/.claude.json will likely contain lots of entries.
Providing an API key per user
To use a separate API key per user, set ANTHROPIC_AUTH_TOKEN in ~/.claude/settings.json to your own key:
"ANTHROPIC_AUTH_TOKEN": "<your-api-key>"The proxy must be started without --apiKey, otherwise it uses the configured key instead.
Starting Claude Code with Privatemode
Start Claude Code with the --model flag pointing to the model served by Privatemode:
claude --model kimi-latestPrivatemode offers kimi-latest (recommended) or glm-latest for coding with Claude Code.
You can also set the model via the environment variable ANTHROPIC_MODEL.
You will be greeted with a screen like the following. You are now ready to "vibe code" confidentially 🥳