Updated:

Claude Code Setup

Claude Code is an official command-line tool provided by Anthropic, allowing you to use Claude AI directly in the terminal.

Base URL and routes

The examples use the Mainland China route, https://api-lb.cubence.ai. For global use, set the Base URL to https://api.cubence.ai; outside Mainland China, you can use https://api.cubence.com. Keep any request path when switching routes. See API endpoints and Base URL configuration.


Installation

npm install -g @anthropic-ai/claude-code

Open Configuration Directory

Press Win + R, enter the following path to open the configuration directory:

%userprofile%\.claude

If you cannot see the folder, you need to enable "Show hidden items" in File Explorer.

Create Configuration File

Create settings.json file:

settings.json
{
"env": {
  "ANTHROPIC_AUTH_TOKEN": "your-api-key-here",
  "ANTHROPIC_BASE_URL": "https://api-lb.cubence.ai",
  "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
},
"permissions": {
  "allow": [],
  "deny": []
},
"apiKeyHelper": "echo 'your-api-key-here'"
}

Please replace your-api-key-here with the API Key created on the Cubence platform.

Claude defaults to a 1M-context model, which burns tokens fast on long sessions. Add "CLAUDE_CODE_AUTO_COMPACT_WINDOW": 200000 to env to trigger auto-compaction at 200K tokens — effectively pinning the context to 200K for lower cost and more stable behavior.

Verify Configuration

Run claude in the terminal to verify the configuration.


Configuration Method 2: Temporary Terminal Configuration

Only effective for the current terminal window, needs to be reconfigured after closing.

$env:ANTHROPIC_BASE_URL="https://api-lb.cubence.ai"
$env:ANTHROPIC_AUTH_TOKEN="your-api-key-here"

VSCode Extension Forced Login Solution

If the Claude Code extension in VSCode requires forced login, you can resolve it as follows:

Create Configuration File

Create config.json file in the ~/.claude/ directory

Add Configuration Content

Add the following content:

config.json
{
"primaryApiKey": "cubence"
}

Restart VSCode

Restart VSCode to apply the configuration.


Having Issues?

Check the Claude Code FAQ, or get help through pre-sales and after-sales support.