Moonshot closes Kimi K2 to users registering on its platform from October 31, 2026. You can still use Claude Code with Kimi, DeepSeek or GLM: point the local CLI at a vendor's Anthropic-compatible endpoint or Requesty, set ANTHROPIC_AUTH_TOKEN and ANTHROPIC_MODEL, then launch claude.
How Claude Code uses another model
Claude Code is the coding agent: it reads files, requests model responses and runs tools according to your permission settings. The model generates the next response. ANTHROPIC_BASE_URL tells the CLI where to send Messages API requests, and ANTHROPIC_AUTH_TOKEN supplies the Bearer credential. Anthropic documents both variables.
With a direct route, the endpoint belongs to the model provider. With Requesty, the endpoint belongs to us and we translate the request format for supported non-Anthropic models. Our Messages API reference describes the connection.

Anthropic states that it does not support routing Claude Code to non-Claude models through any gateway. The providers and Requesty document these routes; Anthropic does not endorse them. Their API billing is separate from a Claude subscription.
DeepSeek V4.1 Flash 1017 has MIT-licensed model weights, but the recipes below use hosted inference. Self-hosting the weights is a separate deployment and requires an endpoint compatible with Claude Code's Messages requests.
The examples use the local CLI in Bash or Zsh on macOS or Linux. In Windows PowerShell, use $env:NAME = "value" for literal values, and $env:ANTHROPIC_AUTH_TOKEN = $env:DEEPSEEK_API_KEY to copy a key from another environment variable. DeepSeek's guide shows the full PowerShell configuration.
For supervisor-hosted background sessions, use an appropriate Claude Code settings file: shell exports alone do not reliably reach those sessions. These are separate from subagents within a session. With a non-Anthropic base URL, Remote Control is disabled and MCP tool search is off by default. Enable tool search only if the endpoint supports tool_reference blocks. See Anthropic's environment reference.
Use Claude Code with DeepSeek directly
- 1Install the CLI and get a key
Follow Anthropic's installation guide. On macOS or Linux, the native installer is:
Shellcurl -fsSL https://claude.ai/install.sh | bashRun
claude --version, create a key on the DeepSeek platform, and add API balance. For the Sonnet 5.5 example below, use Claude Code v2.1.284 or later; a native installation can be updated withclaude update.Put the key in
ANTHROPIC_AUTH_TOKENfrom your secret manager or shell. For example, if your secret manager has loaded the key intoDEEPSEEK_API_KEY, runexport ANTHROPIC_AUTH_TOKEN="$DEEPSEEK_API_KEY"in this terminal. The key remains in the process environment. Keep it out of committed files and bug reports. - 2Set the endpoint and model
Then run this in the same terminal, from your project directory:
Shellexport ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic" export ANTHROPIC_MODEL="deepseek-flash[1m]" export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-flash[1m]" export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]" export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash" export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash" claudeThese settings follow DeepSeek's Claude Code guide. The quotes preserve the literal suffix in shell configurations that expand glob patterns in assignments. Before sending a prompt, check
/status: a settings-fileenventry can override an export, andCLAUDE_CODE_USE_BEDROCK,CLAUDE_CODE_USE_VERTEXorCLAUDE_CODE_USE_FOUNDRYselects cloud credentials instead. See Anthropic's authentication precedence. - 3Check the connection and a tool loop
In
/status, confirm the base URL, credential source and model. Check your permission mode and rules. In the CLI, press Shift+Tab until the status bar shows manual mode if you want prompts for actions requiring approval. Existing allow rules can still approve actions without a prompt.On a disposable branch, ask: "Read the existing tests, add one failing test for a small change, implement the fix, run the test suite, and summarize the changed files."
Read each permission request as it comes up. Confirm that the agent read files, made an edit and produced actual test output. Saying hello only proves the connection works; this task checks the tool loop too.
DeepSeek's pricing page identifies deepseek-flash as an alias for DeepSeek V4.1 Flash 1017. Aliases can change, so record the served model and check the bill when comparing runs.
As of October 2026, direct DeepSeek Flash costs $0.15 per million uncached input tokens and $0.60 per million output tokens off-peak. Peak rates are $0.30 and $1.20. Peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC on weekdays, excluding Chinese public holidays. These direct API rates are separate from the Requesty catalog rates below.
DeepSeek also documents web search and fetch for its direct Claude Code integration. Model tokens are billed throughout. Search and fetch calls through Claude Code have no per-call charge until October 31, 2026 at 16:00 UTC. After that, search and fetch each cost $0.75 per 1,000 successful calls, in addition to model tokens. See DeepSeek's Claude Code guide and pricing.
Use Claude Code with GLM or Kimi directly
Pick a vendor tab and open a fresh terminal. Put that vendor's key in ANTHROPIC_AUTH_TOKEN, then run the commands from your project directory. If your secret manager loads the Z.AI key into ZAI_API_KEY, run export ANTHROPIC_AUTH_TOKEN="$ZAI_API_KEY". For a Moonshot key loaded into MOONSHOT_API_KEY, run export ANTHROPIC_AUTH_TOKEN="$MOONSHOT_API_KEY".
Create a standard API key with account balance or a usage bundle, or a Coding Plan key with available plan quota, on Z.AI.
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_MODEL="glm-5.3[1m]"
export ANTHROPIC_DEFAULT_OPUS_MODEL="glm-5.3[1m]"
export ANTHROPIC_DEFAULT_SONNET_MODEL="glm-5.3[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3-flash[1m]"
claudeThe endpoint and family mappings follow Z.AI's Claude Code setup. The main model is set explicitly here.
Create a key on the Kimi platform and top up at least $1 to use Kimi K3.
export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_OPUS_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_SONNET_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="kimi-k3[1m]"
export ANTHROPIC_DEFAULT_FABLE_MODEL="kimi-k3[1m]"
export CLAUDE_CODE_SUBAGENT_MODEL="kimi-k3[1m]"
claudeThis direct recipe uses Kimi K3. The price table below lists Kimi K3.1 Pro through Requesty, a different model.
This adapts Moonshot's Claude Code example: it uses K3 for Haiku as well as the other roles. Moonshot's example uses K2.7 for Haiku, but its Messages API schema lists K3 models for that endpoint.
The GLM key determines the bill
Z.AI separated its standard API and Coding Plan keys on October 16, 2026. For new keys, a standard key uses account balance or bundles, while a Coding Plan key uses plan quota across supported endpoints. A shared endpoint does not change the key's billing type. Older keys labeled Compatible follow different rules based on endpoint and account history; see Z.AI's key management notice. Requesty's pay-as-you-go route is separate from a direct Z.AI Coding Plan.
What about Kimi K2?
Moonshot's pricing notice says K2 models become unavailable to newly registered users on its platform starting October 31, 2026. It plans to retire K2 by the end of December 2026.
That planned retirement also applies to Requesty's Moonshot-hosted moonshot/kimi-k2.7-code route. The new-user cutoff depends on the upstream account; an independently hosted K2 model has its own availability. Requesty's catalog lists the Moonshot ID in the table below for users comparing a migration. Given the conflict between Moonshot's direct Claude Code guide and its Messages schema, the direct recipe above uses K3.
Switch models with one Requesty key
Requesty gives you one key to switch the main Claude Code model between DeepSeek, GLM, Kimi and Claude with one environment variable; teams can also set per-key spend limits. Sign up, create a key, add prepaid credits for the paid models in this guide, and put the Requesty key in ANTHROPIC_AUTH_TOKEN in a fresh terminal. If your secret manager has loaded it into REQUESTY_API_KEY, run export ANTHROPIC_AUTH_TOKEN="$REQUESTY_API_KEY" before the following commands:
export ANTHROPIC_BASE_URL="https://router.requesty.ai"
export ANTHROPIC_MODEL="deepseek/deepseek-v4.1-flash-1017"
claudeTo switch the main model, uncomment and run one line before starting the next session:
# export ANTHROPIC_MODEL="zai/glm-5.3-flash"
# export ANTHROPIC_MODEL="moonshot/kimi-k3.1-pro"
# export ANTHROPIC_MODEL="anthropic/claude-sonnet-5-5"The Requesty base is https://router.requesty.ai, without /v1 or /anthropic. See our Claude Code agent guide. Requesty has 600+ models.
Changing ANTHROPIC_MODEL switches the main model, but family aliases and CLAUDE_CODE_SUBAGENT_MODEL pins remain separate. Update or remove old role pins when switching providers. Custom subagent definitions and per-invocation model choices can take precedence over the subagent variable; built-in subagents also have their own selection rules.

Anthropic's environment reference marks ANTHROPIC_SMALL_FAST_MODEL as deprecated. Use ANTHROPIC_DEFAULT_HAIKU_MODEL to set the Haiku alias and background model. ANTHROPIC_DEFAULT_OPUS_MODEL, ANTHROPIC_DEFAULT_SONNET_MODEL and ANTHROPIC_DEFAULT_FABLE_MODEL control their respective aliases.
For a team, issue a key per developer or agent and use usage analytics to inspect costs and model usage. To see available IDs, call the models endpoint:
curl https://router.requesty.ai/v1/models \
-H "Authorization: Bearer $ANTHROPIC_AUTH_TOKEN"After a task, check Requesty logs for the served model.
DeepSeek vs GLM vs Kimi vs Claude: price and context
The table is a snapshot of the Requesty model catalog in October 2026. Prices are upstream provider rates in US dollars per 1 million tokens for the named host and model, before Requesty's pay-as-you-go fee. They are not Z.AI Coding Plan prices. Context is the catalog window in tokens.
| Requesty model ID | Input | Output | Cache read | Context |
|---|---|---|---|---|
deepseek/deepseek-v4.1-flash-1017 | $0.30 | $1.20 | $0.006 | 1,000,000 |
zai/glm-5.3-flash | $0.15 | $0.50 | $0.03 | 1,000,000 |
zai/glm-5.3 | $1.40 | $4.40 | $0.26 | 1,000,000 |
moonshot/kimi-k2.7-code | $0.95 | $4.00 | $0.19 | 262,144 |
moonshot/kimi-k3.1-pro | $2.00 | $10.00 | $0.20 | 1,048,576 |
anthropic/claude-sonnet-5-5 | $2.00 | $10.00 | $0.20 | 1,000,000 |
anthropic/claude-opus-5-5 | $4.00 | $20.00 | $0.20 | 1,000,000 |
The catalog API reports per-token prices; the table multiplies them by 1 million. Cache writes can carry a separate charge. For prepaid accounts, Requesty charges a 5% service fee on top of credit top-ups, with no seat fees or minimums: a $100 top-up costs $105 and credits $100 to the balance. See billing details and pricing.
Now for the question the price table cannot answer: what does an accepted change cost? Assume a task consumes 1 million uncached input tokens and 200,000 output tokens across its requests, with no cache writes or tool charges. At the listed catalog rates, the balance deduction for DeepSeek Flash is $0.30 + (0.2 x $1.20) = $0.54. For Sonnet it is $2.00 + (0.2 x $10.00) = $4.00. If funded entirely with paid prepaid credits, the proportional top-up costs are $0.54 x 1.05 = $0.567 and $4.00 x 1.05 = $4.20, before taxes or currency conversion.
A completed task can consume different tokens, need retries or fail. At the same token totals per attempt, eight DeepSeek attempts cost 8 x $0.54 = $4.32 in catalog-rate credits, more than one Sonnet attempt at $4.00. Record the cost per accepted change alongside the token price.
Context is the space for the conversation and generated content. It does not mean Claude Code keeps the entire repository in memory. The CLI's compaction settings and the host's limit also affect how much context remains available.
Claude Code assumes 200,000 tokens for an unrecognized model ID without the [1m] suffix. For an unrecognized, untagged gateway ID, CLAUDE_CODE_MAX_CONTEXT_TOKENS sets the window Claude Code assumes; use the exact host's documented limit. This changes the client assumption, not the model's capacity. Revisit the setting when switching models: Kimi K2.7's catalog window, for example, is 262,144 tokens. See Anthropic's custom model context guidance.
For Requesty Sonnet 5.5 with 1M context, set ANTHROPIC_DEFAULT_SONNET_MODEL to anthropic/claude-sonnet-5-5 before launching, then run /model sonnet[1m] in the session, following Anthropic's third-party alias pinning guidance. Check /status, /context and Requesty logs to inspect the selected route and Claude Code's view of the window. DeepSeek and Z.AI publish different compaction settings in their direct guides; check the host's window before applying them elsewhere.
Tool calls, thinking and cache behavior
A model that answers a question can still fail during an agent loop. Claude Code must receive a valid tool request, run the tool and send the result back. The model then needs to continue from that result. The Messages format does not make every field behave the same way.
| Area | What to check |
|---|---|
| Tool calls | On direct DeepSeek, tool_choice: any is treated as auto, and each tool_use needs a matching tool_result. See DeepSeek's compatibility guide. |
| Thinking | DeepSeek treats adaptive as enabled and ignores budget_tokens. Moonshot says direct K2.7 Code rejects thinking disabled; its Claude Code guide shows the error. |
| Cache | Direct DeepSeek has best-effort prefix caching even though it ignores content-level cache markers. Direct Kimi's Messages API uses top-level cache controls and a five-minute default; cache writes are billed separately. |
| Context | Compare the window for the exact model and host. The [1m] suffix in the direct examples does not expand an upstream model's limit. |
Check cache-read and cache-write usage on the selected route. A low cache-read rate helps only when repeated prefixes are eligible and hit the cache. The same model on another host can have different rates or capabilities.
If image input is part of your task, check the provider's model documentation as well. Z.AI describes glm-5.3 as text-only in its model guide, while the Requesty catalog reports vision support for the zai listing. Test the exact route before relying on images.
Troubleshoot the connection
| Symptom | Check |
|---|---|
| 401 or authentication failure | Confirm the base URL matches the key issuer and that the key has balance or plan quota. Check /status for the active credential source. |
| Model not found | Use the exact ID for the selected endpoint. For Requesty, check the authenticated models list and your organization's approved models. |
| New model or endpoint is ignored | Inspect user, project and managed settings; start a new session after changing exports. /model and --model can override ANTHROPIC_MODEL. |
| Main agent works, background task fails | Check Haiku, Fable and subagent settings for IDs from the previous provider. For supervisor-hosted background sessions, check the settings file separately. |
| Hello works, coding task fails | Run the read, edit and test loop above. Inspect the underlying error, model tool support, thinking mode and context usage. |
A signed-in Claude apps gateway also takes precedence over the credentials and cloud flags above. Check /status and ask your administrator before changing an organization-managed gateway configuration.
Anthropic's settings reference explains user, project and local settings. Merge changes into an existing file instead of deleting it. Keys stored in settings are plaintext; keep them out of committed project files and bug reports. For the broader variable reference, see our Claude Code environment variables guide.
Which model should you try first?
Pick GLM 5.3 Flash or DeepSeek Flash for an inexpensive edit loop: they have the lowest input and output rates in the table. If the same task fails twice, try Sonnet 5.5 on a clean branch and compare the result. Pick Kimi K3.1 Pro if you are moving a K2 workflow and want to evaluate Moonshot's newer model.
Run the same read, edit and test task on each route this week. Stop if the agent repeats failed edits, changes unrelated files, or claims tests passed without test output. Review the patch and compare the total cost of accepted changes.
Claude Code model evaluation
0 of 6 done
Include a subagent task if your team relies on subagents. Hosted models receive the repository context sent in requests, so choose the host and data agreement accordingly. If you need EU processing, Requesty's EU routing guide separates the gateway region from the model's inference location.
Frequently asked questions
- Can I use Claude Code with DeepSeek instead of Claude?
- Yes. Point Claude Code to DeepSeek's Anthropic-compatible endpoint, supply a DeepSeek API key, and set the model to deepseek-flash[1m]. You can also select a DeepSeek model through Requesty. Anthropic does not support non-Claude models through third-party gateways.
- How do I use GLM with Claude Code?
- Set ANTHROPIC_BASE_URL to https://api.z.ai/api/anthropic, supply a Z.AI API key, and select a GLM model such as glm-5.3[1m]. For new Z.AI keys, the key type determines whether supported calls use standard API billing or a GLM Coding Plan.
- Can I use Kimi K2 with Claude Code?
- Requesty lists the Moonshot-hosted model moonshot/kimi-k2.7-code, subject to access and availability. Moonshot closes K2 to newly registered users on its platform from October 31, 2026, and plans to retire the series by the end of December; that retirement also applies to Requesty's Moonshot-hosted route. Moonshot's direct Claude Code guide includes K2.7, but its Messages API schema lists only K3 models.
- Can I switch DeepSeek, GLM and Kimi with one API key?
- Yes. Requesty's Anthropic-compatible endpoint accepts a Requesty key and provider/model IDs. Change ANTHROPIC_MODEL before launching Claude Code, and review separate family pins and subagent model settings.
- Is Claude Code with DeepSeek cheaper than Claude?
- In the October 2026 Requesty catalog snapshot, DeepSeek V4.1 Flash 1017 has lower listed input and output token rates than Claude Sonnet 5.5. The cost of a completed task also depends on token usage, cache writes and reads, retries, and whether the task succeeds.
- Why is Claude Code using the wrong model or endpoint?
- Claude Code settings files can override the same environment variables exported in your shell. Check /status, settings file env entries, model aliases and subagent settings, then start a new session after changing shell exports.
- JUN '26
Claude Code Environment Variables: How to Set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN
A complete reference for the Claude Code environment variables that control where requests go: ANTHROPIC_BASE_URL, ANTHROPIC_AUTH_TOKEN, ANTHROPIC_MODEL and more. Set them in your shell or settings.json, with copy and paste examples.
- SEP '26
Claude Code API Key: Setup Without a Subscription
Use a Claude Code API key instead of Pro or Max. Follow macOS, Linux and Windows setup, verify billing, compare costs and switch back without hidden overrides.
- MAY '26
Agentic Coding Tools Compared (2026): Claude Code vs Cursor vs Codex vs Aider
Claude Code, Cursor 3, OpenAI Codex, Aider, Roo Code, and Cline are all shipping autonomous agents in 2026. Here is how they compare on architecture, pricing, benchmarks, and which LLM gateway they support.
