Claude Code API configuration
Using Claude in China, the API is actually not very friendly; besides Claude's official models, can I use other AI models?
This section teaches you in detail how to configure the APIs of multiple mainstream domestic AI models, enabling Claude Code to support:
| Vendor/Brand | Introduction | API application entry (click to access) |
|---|---|---|
| DeepSeek (domestic, cost-effective) | Official models: |
deepseek-v4-flash
deepseek-v4-pro
deepseek-chat (将于 2026/07/24 弃用)
deepseek-reasoner (将于 2026/07/24 弃用) | [https://platform.deepseek.com/api_keys](https://platform.deepseek.com/api_keys) |
| Alibaba Bailian (Tongyi Qianwen) | Alibaba Cloud unified LLM gateway, supporting the latest models such as Qianwen, GLM, Kimi, MiniMax | https://bailian.console.aliyun.com | | GLM (Zhipu Qingyan) | The Tsinghua-affiliated ChatGLM series, supporting GLM-4, GLM-3-Turbo, etc. | https://open.bigmodel.cn | | MiniMax | Domestic multimodal model, supporting mixed calls of text, voice, and images | https://platform.minimaxi.com |
After entering the corresponding console, register/log in → complete real-name authentication → create an API Key to start calling.
API management tools
With many platforms, configuration becomes troublesome; we can use the third-party tool CC Switch to easily manage the API configurations of these popular tools:https://github.com/farion1231/cc-switch/, fully supported on Windows / macOS / Linux.
CC Switch is an all-around auxiliary tool for Claude Code / Codex / Gemini CLI.
CC Switch can help us easily manage the API configurations of these popular tools, like giving your developer toolbox a smart organizing assistant in which all tool configurations are managed in an orderly way.

Download addresses for installation packages on each platform:https://github.com/farion1231/cc-switch/releases。

For specific operation settings, refer to the article:https://www.runoob.com/ai-agent/cc-switch.html
If you don't mind the trouble, you can follow the instructions below to configure it yourself.
Connecting DeepSeek to Claude Code
Required information:
-
API key: https://platform.deepseek.com/api_keys Apply for API keys.
-
BASE_URL: the URL for API requests is https://api.deepseek.com/anthropic。
Configure in environment variables
Linux / Mac users execute the following command to configure the DeepSeek Anthropic API environment variables, where the API Key is obtained DeepSeek Platform at:
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<你的 DeepSeek API Key>
export ANTHROPIC_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_OPUS_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_SONNET_MODEL=deepseek-v4-pro[1m]
export ANTHROPIC_DEFAULT_HAIKU_MODEL=deepseek-v4-flash
export CLAUDE_CODE_SUBAGENT_MODEL=deepseek-v4-flash
export CLAUDE_CODE_EFFORT_LEVEL=max
Windows users execute:
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="<你的 DeepSeek API Key>"
$env:ANTHROPIC_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-v4-pro[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-v4-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"
Note: Add [1m] to the model configuration, then remember to set thinking intensity to max, so it can run at full capacity.
Parameter Description:
Simplified to the first three columns (parameter name / example value / function description) as follows:
| Parameter name | Example value | Description |
|---|---|---|
ANTHROPIC_BASE_URL |
https://api.deepseek.com/anthropic |
Specify the API gateway address, forwarding Anthropic SDK requests to DeepSeek |
ANTHROPIC_AUTH_TOKEN |
<你的 DeepSeek API Key> |
API authentication Token, used to access the DeepSeek service |
ANTHROPIC_MODEL |
deepseek-v4-pro |
Default main model used |
ANTHROPIC_DEFAULT_OPUS_MODEL |
deepseek-v4-pro |
Map Claude Opus model |
ANTHROPIC_DEFAULT_SONNET_MODEL |
deepseek-v4-pro |
Map Claude Sonnet model |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
deepseek-v4-flash |
Map Claude Haiku model (lightweight and fast) |
CLAUDE_CODE_SUBAGENT_MODEL |
deepseek-v4-flash |
Model used by the sub Agent (usually for fast tasks) |
CLAUDE_CODE_EFFORT_LEVEL |
max |
Control reasoning intensity and thinking depth |
Then enter the project directory and run the claude command to start using it.
cd my-project
claude

After starting Claude Code, specify using DeepSeek:
claude --model deepseek-v4-pro
Or switch in interactive mode:
> /model deepseek-v4-pro
Enter /model to view supported models:

Reference documentation:https://api-docs.deepseek.com/zh-cn/guides/coding_agents
Connecting Alibaba Bailian to Claude Code
The Qwen (Tongyi Qianwen) model series of Alibaba Cloud Bailian supports an Anthropic API compatible interface; by modifying the following parameters, you can call the Qwen model series in Claude Code.
-
ANTHROPIC_API_KEY (or ANTHROPIC_AUTH_TOKEN): replace with the Bailian API Key, apply at:https://bailian.console.aliyun.com/cn-beijing/?tab=model#/api-key。
-
ANTHROPIC_BASE_URL: replace with the Bailian compatible endpoint address https://dashscope.aliyuncs.com/apps/anthropic。
You can directly purchase a resource package, which is more cost-effective:https://cn.aliyun.com/benefit?from_alibabacloud=&userCode=i5mn5r7m
-
Model name: replace with a model name supported by Bailian (for example qwen3-max, qwen3-coder-plus, etc.)
macOS/Linux:
Create and open the configuration file ~/.claude/settings.json.
~ represents the user's home directory. If the .claude directory does not exist, create it first by running mkdir -p ~/.claude in the terminal.
Edit the configuration file:
vim ~/.claude/settings.json
Replace YOUR_API_KEY with your dedicated API Key.
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
"ANTHROPIC_BASE_URL": "https://dashscope.aliyuncs.com/apps/anthropic",
"ANTHROPIC_MODEL": "qwen3-coder-plus"
}
}
Open a new terminal for the environment variable configuration to take effect.
Windows:
Run the following commands in CMD to set environment variables:
setx ANTHROPIC_AUTH_TOKEN "YOUR_API_KEY"
setx ANTHROPIC_BASE_URL "https://dashscope.aliyuncs.com/apps/anthropic"
setx ANTHROPIC_MODEL "qwen3-coder-plus"
Replace YOUR_API_KEY with your plan's dedicated API Key.
Open a new CMD window and run the following commands to check whether the environment variables took effect.
echo %ANTHROPIC_AUTH_TOKEN%
echo %ANTHROPIC_BASE_URL%
echo %ANTHROPIC_MODEL%
Run the following commands in PowerShell to set environment variables:
# Replace YOUR_API_KEY with the plan-specific API Key
[Environment]::SetEnvironmentVariable("ANTHROPIC_AUTH_TOKEN", "YOUR_API_KEY", [EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("ANTHROPIC_BASE_URL", "https://dashscope.aliyuncs.com/apps/anthropic", [EnvironmentVariableTarget]::User)
[Environment]::SetEnvironmentVariable("ANTHROPIC_MODEL", "qwen3-coder-plus", [EnvironmentVariableTarget]::User)
Open a new PowerShell window and run the following commands to check whether the environment variables took effect.
echo $env:ANTHROPIC_AUTH_TOKEN
echo $env:ANTHROPIC_BASE_URL
echo $env:ANTHROPIC_MODEL
Connecting the Qwen model series in Claude Code
During a conversation, run /model <
/model qwen3-coder-plus
You can also create the .claude/settings.json file in the project root directory and write model configuration into it for permanent configuration.

{
"env": {
"ANTHROPIC_MODEL": "qwen3-coder-plus",
"ANTHROPIC_SMALL_FAST_MODEL": "qwen-flash"
}
}
Start Claude and you can see the configuration information:

Connecting Zhipu Large Models to Claude Code
In this section we use the ~/.claude/settings.json file to configure the large model; before starting, you need to obtain an API key from the official platform:GLM Coding Plan。
Edit or create the Claude Code configuration file ~/.claude/settings.json, and add or modify the env field in it
# Note to replace your_zhipu_api_key with the API Key you obtained in the previous step
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your_zhipu_api_key",
"ANTHROPIC_BASE_URL": "https://open.bigmodel.cn/api/anthropic",
"API_TIMEOUT_MS": "3000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1
}
}
Run claude to start Claude Code, then enter /status to confirm the model status:

If not, you can enter /config to switch models.
