Home / Guides / Coding tools

Use DeepSeek, GLM and Kimi in Claude Code

Updated 2026-10-18 · A few environment variables let Claude Code run on DeepSeek, GLM, Kimi or MiniMax.

Connection details

Base URL (OpenAI compatible)
https://api.aifans.fan/v1
Base URL (Anthropic compatible)
https://api.aifans.fan
API key
Create one in the console; it starts with sk- (no account yet? sign up)
Recommended models
deepseek-v4.1-flash, deepseek-v4-pro (all models and prices)

Claude Code talks to its model over the Anthropic Messages API. AIFans API offers an Anthropic-compatible /v1/messages endpoint, so a few environment variables are enough to run Claude Code on DeepSeek, GLM, Kimi or MiniMax.

1. Get an API key

Sign up and create an API key. Give Claude Code its own key with a daily spending limit, so a long unattended session cannot run up a large bill.

2. Configure Claude Code

Edit ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json) and add:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.aifans.fan",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_API_KEY",
    "ANTHROPIC_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-v4-pro",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-v4.1-flash",
    "CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-v4-pro"
  }
}

ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL choose the model behind Claude Code's main tiers; ANTHROPIC_DEFAULT_HAIKU_MODEL handles light background tasks, so a fast, cheap model saves money there. Model names are on Models and prices.

3. Start it

claude

Send a message to test. Tokens and cost of every call appear in the Usage page of the console.

Troubleshooting

  • 401: check that ANTHROPIC_AUTH_TOKEN holds the whole key, and that the base URL does not end in /v1.
  • 402: your balance is used up; top up in the console.
  • 403 key_quota_exceeded: the key reached a spending limit you set; change it in the console.
  • Errors about tools: some models do not support every built-in tool; try adding "ENABLE_TOOL_SEARCH": "false" to env.
  • Empty answers: most models think first, and thinking counts as output tokens; do not set a tiny max_tokens. For the DeepSeek V4 family you can also switch thinking off with "thinking": {"type": "disabled"}.

All error codes are in the API reference.

Related guides