CodeBuddy CLI access
CodeBuddy CLI officially supports adding custom models through models.json, and supports using environment variables to reference API Keys. This article uses ShangHai Do’s OpenAI Chat Completions interface.
CLI means a client operated through commands in a terminal. If not yet installed, follow CodeBuddy CLI installation guide to install the client.
configuration file location
- User level:
~/.codebuddy/models.json - Project level:
<项目根目录>/.codebuddy/models.json
Project-level configuration takes precedence over user-level configuration. Windows users can create the .codebuddy folder in the user directory; if the current version provides a configuration directory command, the path displayed on the client shall prevail.
Recommended configuration
{
"models": [
{
"id": "qwen3.8-flash",
"name": "ShangHai Do qwen3.8-flash",
"vendor": "ShanHai",
"apiKey": "${SHANHAI_API_KEY}",
"url": "https://shanghaido.com/v1/chat/completions",
"supportsToolCall": true,
"supportsImages": false
}
],
"availableModels": ["qwen3.8-flash"]
}
CodeBuddy CLI official description: Custom models apiKey and url support ${环境变量名} expansion. First set the environment variables:
Windows PowerShell:
$env:SHANHAI_API_KEY = "YOUR_API_KEY"
codebuddy --model qwen3.8-flash
macOS / Linux:
export SHANHAI_API_KEY="YOUR_API_KEY"
codebuddy --model qwen3.8-flash
url Usually write the complete:
https://shanghaido.com/v1/chat/completions
This is different from most editors that “fill in the Base URL to /v1”. Do not change the full interface address to just /v1 unless the current CodeBuddy CLI version is explicitly configured to use another protocol such as api: "openai-responses".
Capability field
supportsToolCall: true: Allow Agent to use tools; only enabled if the model supports tool invocation.supportsImages: false: This example does not claim image input capabilities.supportsReasoning: Fill in only if both model and client protocol are confirmed to be supported.maxInputTokens,maxOutputTokens: Can be filled in according to the model details page; omit or use conservative values when unsure.
Usage and troubleshooting
CodeBuddy CLI supports automatic reloading after configuration file changes. Run the general Q&A first, then the small code tasks.
- Configuration not loaded: Check if JSON format, file location and environment variables exist.
- Model not displayed: Check whether
availableModelscontainsqwen3.8-flash, or temporarily delete this field to allow the model list to be fully displayed. - Request 404: Confirm that
urlis a complete/v1/chat/completionsand there are no duplicate splicing paths. - Token leakage risk: Do not write the real token directly in
models.json, and do not submit the file to the repository.
official information
encountered a problem
If you encounter problems with calling or configuration, please contact the site customer service and provide the model name, error time and error information to facilitate troubleshooting.