This guide shows how to wire OpenCode into the proxy so every model from every configured upstream provider appears as a native OpenCode model.
OpenCode supports any OpenAI-compatible API endpoint via the
@ai-sdk/openai-compatible provider. The proxy runs locally and presents
itself as one; each OpenCode model id routes through the provider router
to whichever upstream declares it (Command Code, OpenAI-compat, native
Anthropic or Gemini).
OpenCode ──> localhost:18080/v1/chat/completions ──> Command Code API
cd /path/to/cmdcode
cargo run --release
# listening on http://127.0.0.1:18080Or use systemd (see setup.md).
Add a custom provider in your opencode.json:
Key fields:
npm: Must be@ai-sdk/openai-compatible(OpenCode's OpenAI-compatible provider)options.baseURL: Points to the proxy athttp://localhost:18080/v1(the/v1suffix is required - OpenCode appends/chat/completions)models: Each key is a model ID that the proxy accepts
# Restart to pick up the new config
opencodeAssign the proxy model to specific agents in your opencode.json:
{
"agent": {
"sc-finder": {
"model": "default"
},
"bounty-hunter": {
"model": "default"
}
}
}Or use a specific model directly:
{
"agent": {
"sc-finder": {
"model": "command-code/xiaomi/mimo-v2.5"
}
}
}The proxy auto-discovers models from the installed command-code CLI.
Common models include:
| Model ID | Description |
|---|---|
xiaomi/mimo-v2.5 | MiMo V2.5 (reasoning) |
gpt-5.6-luna | GPT-5.6 Luna (reasoning) |
gpt-5.6-sol | GPT-5.6 Sol (reasoning) |
deepseek/deepseek-v4-pro | DeepSeek V4 Pro (reasoning) |
claude-sonnet-5 | Claude Sonnet 5 (reasoning) |
Models above your subscription plan are rejected (403) by the upstream API.
Control reasoning depth with the reasoning_effort parameter or
model:effort syntax:
{
"model": "claude-sonnet-5:high",
"messages": [{"role": "user", "content": "Analyze this code"}]
}Effort levels: low, medium, high, xhigh, max
The proxy works with any tool that speaks the OpenAI chat completions API:
model_list:
- model_name: command-codelitellm_params:
model: openai/xiaomi/mimo-v2.5api_base: http://127.0.0.1:18080api_key: not-neededcurl http://127.0.0.1:18080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{ "model": "xiaomi/mimo-v2.5", "messages": [{"role": "user", "content": "Hello"}], "stream": true }'fromopenaiimportOpenAIclient=OpenAI(
base_url="http://127.0.0.1:18080",
api_key="not-needed",
)
response=client.chat.completions.create(
model="xiaomi/mimo-v2.5",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)importOpenAIfrom"openai";constclient=newOpenAI({baseURL: "http://127.0.0.1:18080",apiKey: "not-needed",});constresponse=awaitclient.chat.completions.create({model: "xiaomi/mimo-v2.5",messages: [{role: "user",content: "Hello"}],});console.log(response.choices[0].message.content);The official cmd CLI is a monolithic Node.js harness. The proxy gives you:
- Composability - plug into any OpenAI-compatible pipeline
- Multi-tenant - run one proxy, serve multiple tools
- Observability - standard HTTP logs, easy to proxy through nginx
- No vendor lock-in - swap to any OpenAI-compatible provider by changing one URL
- Performance - Rust + Pingora for sub-millisecond overhead
{ "provider": { "command-code": { "npm": "@ai-sdk/openai-compatible", "name": "Command Code", "options": { "baseURL": "http://localhost:18080/v1" }, "models": { "xiaomi/mimo-v2.5": { "name": "MiMo V2.5", "reasoning": true }, "gpt-5.6-luna": { "name": "GPT-5.6 Luna", "reasoning": true } } } }, "model": "default" }