OpenAI-compatible API proxy for Command Code.
Use your Command Code subscription from any OpenAI-compatible client — OpenCode, Claude Code, or plain curl.
Command Code exposes two API surfaces:
| Surface | Protocol | Plan required |
|---|---|---|
/provider/v1/chat/completions |
OpenAI-compatible | Provider tier (paid add-on) |
/alpha/generate |
Custom (Vercel AI SDK stream) | Your standard subscription |
This proxy talks /alpha/generate upstream and standard OpenAI downstream — so your existing plan works from any tool.
# Clone & run from source
git clone https://github.com/thaolaptrinh/commandcode-api-proxy.git
cd commandcode-api-proxy
npm install
npm run build && npm start
# Or run directly (no install)
npx commandcode-api-proxy
# Or install globally
npm install -g commandcode-api-proxy
commandcode-api-proxyOn first run, the proxy prompts for your Command Code API key (get it from https://commandcode.ai/settings). Other ways to provide it are in Authentication.
Provide your API key via --api-key, the CC_API_KEY env var, or save it
with auth login (stored at ~/.config/commandcode-api-proxy/auth.json).
From source, replace
commandcode-api-proxywithnpm run auth --(e.g.npm run auth -- login).
# Save a new API key
commandcode-api-proxy auth login
# Overwrite existing key
commandcode-api-proxy auth login --force
# Remove saved key
commandcode-api-proxy auth logout| Option | Description | Default |
|---|---|---|
--host |
Bind address | 127.0.0.1 |
--port |
Port | 8787 |
--api-key |
Command Code API key | — |
--setup-opencode |
Generate OpenCode provider config | — |
--setup-claude-code |
Generate Claude Code model config | — |
Equivalent env vars (lower priority than CLI flags):
| Env var | Description |
|---|---|
HOST |
Bind address |
PORT |
Port |
CC_API_KEY |
Command Code API key |
CC_API_BASE |
Upstream API base URL |
CC_CLI_VERSION |
CLI version sent upstream |
LOG_LEVEL |
Log level (info, debug, etc.) |
| Endpoint | Protocol |
|---|---|
GET /health |
— |
GET /v1/models |
OpenAI |
POST /v1/chat/completions |
OpenAI |
POST /v1/messages |
Anthropic |
POST /v1/messages/count_tokens |
Anthropic |
All endpoints accept any auth token (use proxy-managed) — the proxy injects
your real Command Code key upstream.
Run setup to auto-generate the provider config at ~/.config/opencode/opencode.json:
npx commandcode-api-proxy --setup-opencodeAll CC models are listed directly — pick the one you want from the model selector.
Or add a commandcode provider manually — point baseURL at the proxy and
use any model ID from the Model aliases table:
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"commandcode": {
"npm": "@ai-sdk/openai-compatible",
"name": "Command Code",
"options": {
"baseURL": "http://127.0.0.1:8787/v1",
"apiKey": "proxy-managed"
},
"models": {
"deepseek-v4-pro": { "name": "DeepSeek V4 Pro" }
}
}
}
}Claude Code only offers three tiers — sonnet, opus, haiku. The setup
maps each tier to a Command Code model via env vars in claude-settings.json:
npx commandcode-api-proxy --setup-claude-codeIf a settings file already exists, re-run with --force to overwrite it.
| Claude Code tier | Env var | Maps to |
|---|---|---|
sonnet |
ANTHROPIC_DEFAULT_SONNET_MODEL |
deepseek/deepseek-v4-pro |
opus |
ANTHROPIC_DEFAULT_OPUS_MODEL |
deepseek/deepseek-v4-pro |
haiku |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
deepseek/deepseek-v4-flash |
Edit those env vars in the settings file to point at other CC models. To force
every claude-* request to a single model regardless of tier, set
ANTHROPIC_DEFAULT_MODEL. Then run:
claude --settings ~/.config/commandcode-api-proxy/claude-settings.jsonOr set an alias:
alias claude-proxy="claude --settings ~/.config/commandcode-api-proxy/claude-settings.json"
claude-proxyShort names work in addition to full model IDs:
| Alias | Maps to |
|---|---|
deepseek-v4-pro, deepseek-v4, deepseek-pro |
deepseek/deepseek-v4-pro |
deepseek-v4-flash, deepseek-flash |
deepseek/deepseek-v4-flash |
kimi-k2.6, kimi2.6 |
moonshotai/Kimi-K2.6 |
kimi-k2.5, kimi2.5 |
moonshotai/Kimi-K2.5 |
glm-5.1 |
zai-org/GLM-5.1 |
glm-5 |
zai-org/GLM-5 |
minimax-m2.7, minimax2.7 |
MiniMaxAI/MiniMax-M2.7 |
minimax-m2.5, minimax2.5 |
MiniMaxAI/MiniMax-M2.5 |
qwen3.6-max, qwen-3.6-max |
Qwen/Qwen3.6-Max-Preview |
qwen3.6-plus, qwen-3.6-plus |
Qwen/Qwen3.6-Plus |
qwen3.7-max, qwen-3.7-max |
Qwen/Qwen3.7-Max |
qwen3.7-plus, qwen-3.7-plus |
Qwen/Qwen3.7-Plus |
step3.5, step-3.5-flash |
stepfun/Step-3.5-Flash |
mimo-v2.5, mimo2.5 |
xiaomi/mimo-v2.5 |
Any model ID is passed through as-is — the proxy does not validate against a fixed list.
MIT
