models.json is a configuration file for customizing the model list and controlling the display of the model dropdown list. This configuration supports two levels:~/.codebuddy/models.json - Global configuration that applies to all projects.<workspace>/.codebuddy/models.json - Project-specific configuration that takes precedence over the user-level configuration.<project-root>/.codebuddy/models.jsonid field. For the availableModels field, the project-level configuration completely overrides the user-level configuration without merging.{"models": [{"id": "model-id","name": "Model Display Name","vendor": "vendor-name","apiKey": "sk-actual-api-key-value","maxInputTokens": 200000,"maxOutputTokens": 8192,"url": "https://api.example.com/v1/chat/completions","temperature": 0.7,"supportsToolCall": true,"supportsImages": true}],"availableModels": ["model-id-1", "model-id-2"]}
Array<LanguageModel>Field | Type | Required | Description |
id | string | Yes | Unique identifier of the model |
name | string | No | Model display name |
vendor | string | No | Model vendor (for example, OpenAI, Google) |
apiKey | string | No | API key, supports environment variable references (see the security configuration instructions below). |
maxInputTokens | number | No | Maximum input tokens |
maxOutputTokens | number | No | Maximum output tokens |
url | string | No | API endpoint URL, supports environment variable references (must be the full API path, typically ending with /chat/completions). |
temperature | number | No | Sampling temperature, ranging from 0 to 2. Higher values produce more random output, while lower values produce more deterministic output. |
supportsToolCall | boolean | No | Tool call support or not |
supportsImages | boolean | No | Image input support or not |
supportsReasoning | boolean | No | Reasoning mode support or not |
relatedModels | object | No | Related model configuration, specifies which model id to use in different scenarios ( lite/reasoning/vision/longContext/subagent). For details, see Configure Related Models. |
url field must be the full API path, typically ending with /chat/completions.https://api.openai.com/v1/chat/completions or http://localhost:11434/v1/chat/completionsapiKey and url fields support the environment variable reference syntax ${VAR_NAME}.${ENV_VAR_NAME}{"models": [{"id": "gpt-4o","name": "GPT-4o","vendor": "OpenAI","apiKey": "${OPENAI_API_KEY}","url": "https://api.openai.com/v1/chat/completions"}]}
# Add to ~/.zshrc or ~/.bashrcexport OPENAI_API_KEY="sk-your-actual-api-key"# Or set it temporarily at startup.OPENAI_API_KEY="sk-xxx" codebuddy
# Store the key in the Keychainsecurity add-generic-password -a "$USER" -s "openai-api-key" -w "sk-xxx"# Configure automatic export in ~/.zshrcexport OPENAI_API_KEY=$(security find-generic-password -s "openai-api-key" -w 2>/dev/null)
models.json to 600 (readable and writable only by the owner).Array<string>{"models": [{"id": "my-custom-model","name": "My Custom Model","vendor": "OpenAI","apiKey": "sk-custom-key-here","maxInputTokens": 128000,"maxOutputTokens": 4096,"url": "https://api.myservice.com/v1/chat/completions","supportsToolCall": true}]}
{"models": [{"id": "gpt-4-turbo","name": "GPT-4 Turbo (Custom Endpoint)","vendor": "OpenAI","url": "https://my-proxy.example.com/v1/chat/completions","apiKey": "sk-your-key-here"}]}
{"availableModels": ["gpt-4-turbo","gpt-4o","my-custom-model"]}
.codebuddy/models.json):{"models": [{"id": "project-a-model","name": "Project A Model","vendor": "OpenAI","url": "https://project-a-api.example.com/v1/chat/completions","apiKey": "sk-project-a-key","maxInputTokens": 100000,"maxOutputTokens": 4096}],"availableModels": ["project-a-model", "gpt-4-turbo"]}
~/.codebuddy/models.json (user level)<workspace>/.codebuddy/models.json (project level)models.json are automatically tagged with the custom tag for easy identification and filtering in the UI.SmartMerge policy:availableModels filtering is performed after all merges are complete.url field for all custom models typically ends with /chat/completions.https://api.openai.com/v1/chat/completionshttps://api.myservice.com/v1/chat/completionshttp://localhost:11434/v1/chat/completionshttps://my-proxy.example.com/v1/chat/completions
https://api.openai.com/v1https://api.myservice.comhttp://localhost:11434
{"models": [{"id": "openai/gpt-4o","name": "open-router-model","url": "https://openrouter.ai/api/v1/chat/completions","apiKey": "sk-or-v1-your-openrouter-api-key","maxInputTokens": 128000,"maxOutputTokens": 4096,"supportsToolCall": true,"supportsImages": false}]}
url is configured, it takes effect with "full replacement" semantics even if the id is the same as the cloud, and it will not be merged or overwritten by cloud defaults):{"models": [{"id": "deepseek-v4-pro","name": "DeepSeek V4 Pro","vendor": "DeepSeek","url": "https://api.deepseek.com/v1/chat/completions","apiKey": "${DEEPSEEK_API_KEY}","maxInputTokens": 128000,"maxOutputTokens": 8192,"supportsToolCall": true,"supportsImages": false},{"id": "deepseek-v4-flash","name": "DeepSeek V4 Flash","vendor": "DeepSeek","url": "https://api.deepseek.com/v1/chat/completions","apiKey": "${DEEPSEEK_API_KEY}","maxInputTokens": 128000,"maxOutputTokens": 8192,"supportsToolCall": true,"supportsImages": false}],"availableModels": ["deepseek-v4-pro","deepseek-v4-flash"]}
export DEEPSEEK_API_KEY="<your-deepseek-api-key>"codebuddy --model deepseek-v4-pro
models.json, you can also integrate with DeepSeek entirely through environment variables. See Environment Variables for Integrating with DeepSeek Example.relatedModels field of a model entry.Scenario | Purpose | Current status |
lite | A lightweight and fast model for low-value requests such as backend extraction and summarization. It is also the model corresponding to the model: "lite" parameter of the Agent tool. | Effective |
reasoning | Reasoning-enhanced model for complex reasoning that requires deep thinking; the model corresponding to the model: "reasoning" parameter of the Agent tool. | Effective |
subagent | Default model used by subagents and team members | Reserved and not enabled—subagents use an independent subagents parsing chain and do not read this field. |
vision | Vision understanding model for requests that require image processing | Reserved and not enabled—the type is defined, but no call site consumes this variant yet. |
longContext | Long-context model for requests with extremely long contexts | Reserved and not enabled—the type is defined, but no call site consumes this variant yet. |
lite and reasoning variants are consumed in agent-manager and mapped to the model switching logic. The subagent / vision / longContext items are only retained in the type definitions and reserved for future iterations. Writing them into relatedModels now will not cause an error, but they will not take effect either.models.json do not inherit the built-in defaultRelatedModels.relatedModels, and no environment variables or variantModels overrides are present, lite and reasoning fall back to the main model. Subagents do not read relatedModels.subagent, but subagents configured as lite or reasoning still go through this scenario variant resolution chain.{"models": [{"id": "deepseek-v4-pro","name": "DeepSeek V4 Pro","vendor": "DeepSeek","url": "https://api.deepseek.com/v1/chat/completions","apiKey": "${DEEPSEEK_API_KEY}","maxInputTokens": 128000,"maxOutputTokens": 8192,"supportsToolCall": true,"relatedModels": {"lite": "deepseek-v4-flash","reasoning": "deepseek-v4-pro"}},{"id": "deepseek-v4-flash","name": "DeepSeek V4 Flash","vendor": "DeepSeek","url": "https://api.deepseek.com/v1/chat/completions","apiKey": "${DEEPSEEK_API_KEY}","maxInputTokens": 128000,"maxOutputTokens": 8192,"supportsToolCall": true}],"availableModels": ["deepseek-v4-pro","deepseek-v4-flash"]}
lite / reasoning go through this resolution chain):CODEBUDDY_SMALL_FAST_MODEL corresponds to lite, and CODEBUDDY_BIG_SLOW_MODEL corresponds to reasoning)variantModels[variant]variantModels[variant]relatedModels[variant] in the current main model entrydefaultRelatedModels[variant] (applies only to built-in models, and custom models skip this step)variantModels is stored in settings.json and can also be edited through the /model:lite / /model:reasoning commands. It is suitable for fixed mapping of lite / reasoning to specific models at the user or project level, while relatedModels is suitable for making the mapping follow the current main model.CODEBUDDY_CODE_SUBAGENT_MODEL uniformly overrides all subagents.model input parameter of this Agent tool callsubagents.agents.<subagent_name>.modelsubagents.agents.<subagent_name>.modelExplore using literelatedModels.subagent. When a subagent is configured as lite or reasoning, it continues through the scenario variant resolution chain above to obtain a specific model.settings.json:{"subagents": {"agents": {"Explore": { "model": "lite" },"Plan": { "model": "reasoning" }}},"variantModels": {"lite": "<fast-model-id>","reasoning": "<reasoning-model-id>"}}
relatedModels to make scenario mappings follow the main model.variantModels or /model to pin the specific model for lite / reasoning at the user or project level.subagents.agents.<subagent_name>.model or /agents to select a model or scenario variant for each built-in subagent.{"models": [{"id": "gpt-4o","name": "GPT-4o","vendor": "OpenAI","apiKey": "sk-your-openai-key","maxInputTokens": 128000,"maxOutputTokens": 16384,"supportsToolCall": true,"supportsImages": true},{"id": "my-local-llm","name": "My Local LLM","vendor": "Ollama","url": "http://localhost:11434/v1/chat/completions","apiKey": "ollama","maxInputTokens": 8192,"maxOutputTokens": 2048,"supportsToolCall": true}],"availableModels": ["gpt-4o","my-local-llm"]}
availableModels.models configuration is correct.id, name, provider) are provided.フィードバック