Models Hub
Agent Tools

Use CodeBuddy CLI with Models Hub: Env Vars and settings.json

Point Tencent Cloud's CodeBuddy CLI at Models Hub's Claude models using CODEBUDDY_BASE_URL and related environment variables or settings.json, with verification and error troubleshooting.

Edit this page

CodeBuddy CLI is Tencent Cloud's terminal AI coding assistant, modeled on Claude Code both in protocol and configuration: it uses the same _BASE_URL / _API_KEY / _MODEL environment variable pattern, and supports the same env block inside settings.json. Point it at Models Hub, and every chat and code edit inside codebuddy uses your Models Hub balance for the model you choose. This page covers the connection only, not how to use CodeBuddy CLI itself.

Three things you need

A Models Hub API key, the base URL https://modelsok.com, and a model name. There's no one-click setup — CodeBuddy CLI isn't one of the targets the Models Hub CLI supports.

Prerequisites

  • CodeBuddy CLI installed. Run npm install -g @tencent-ai/codebuddy-code (Node.js 18.20+ required), or on macOS/Linux curl -fsSL https://www.codebuddy.cn/cli/install.sh | bash; codebuddy --version should print a version afterward. See the official install docs for details.
  • A Models Hub API key, created on the Tokens page. The token's group must have access to the models you plan to use.
Use caseModelPricingLive status
Everyday codingclaude-sonnet-4-6PriceAvailability and latency
Harder refactors and long tasksclaude-opus-4-6PriceAvailability and latency
Lightweight background tasksclaude-haiku-4-5PriceAvailability and latency

Model names are authoritative on the pricing page.

Setup

For a quick test, export the environment variables in your current shell:

export CODEBUDDY_API_KEY="your-models-hub-api-key"
export CODEBUDDY_BASE_URL="https://modelsok.com"
export CODEBUDDY_MODEL="claude-sonnet-4-6"

Windows (PowerShell):

$env:CODEBUDDY_API_KEY="your-models-hub-api-key"
$env:CODEBUDDY_BASE_URL="https://modelsok.com"
$env:CODEBUDDY_MODEL="claude-sonnet-4-6"

To make it persistent, edit the user-level ~/.codebuddy/settings.json (%USERPROFILE%\.codebuddy\settings.json on Windows) and add an env block:

{
  "env": {
    "CODEBUDDY_API_KEY": "your-models-hub-api-key",
    "CODEBUDDY_BASE_URL": "https://modelsok.com",
    "CODEBUDDY_MODEL": "claude-sonnet-4-6",
    "CODEBUDDY_SMALL_FAST_MODEL": "claude-haiku-4-5"
  }
}
VariablePurpose
CODEBUDDY_API_KEYYour Models Hub API key
CODEBUDDY_BASE_URLThe base URL — do not append /v1; CodeBuddy CLI builds the path itself
CODEBUDDY_MODELThe default model
CODEBUDDY_SMALL_FAST_MODELThe model used for lightweight background tasks; pick a cheap one

CodeBuddy CLI merges configuration by priority (higher overrides lower): command-line flags > project-local ./.codebuddy/settings.local.json > project-shared ./.codebuddy/settings.json > user-level ~/.codebuddy/settings.json. For team-wide settings, use the project-shared file.

Verify

Run codebuddy in any project and ask something like "describe this directory in one sentence". A normal reply means you're connected. Two more checks: type /model to see the currently active model, and open Usage logs in the Models Hub console; a request under your configured model name appears within seconds.

Common errors

SymptomCauseFix
401 / authentication failureWrong key, stray whitespace, or a disabled tokenRe-copy from the Tokens page
model not found / no available channelMisspelled model name, or the token's group can't access itCheck the name on the pricing page
404 on requestsCODEBUDDY_BASE_URL was set to an OpenAI-style path like /v1/chat/completionsCodeBuddy CLI speaks the Anthropic-compatible protocol — don't append a path suffix to CODEBUDDY_BASE_URL
settings.json edits don't take effectAn already-open session doesn't reread the configRestart codebuddy, or run /clear to start a new session
429Rate limited, usually too much concurrencyRetry shortly; contact support for a higher limit if it persists

More in Troubleshooting.

FAQ

How is it billed? Per input and output token actually consumed, at the price on each model's pricing page; every request is itemized in usage logs.

How is this different from using my Tencent Cloud account directly? Once configured, every CodeBuddy CLI request goes through Models Hub instead of your Tencent Cloud account's quota, and you don't need a separate CodeBuddy subscription.

How do I switch models? Type /model inside CodeBuddy CLI, run codebuddy config set model <model-name>, or edit CODEBUDDY_MODEL and restart.

On this page