Claude Code can be pointed at models from other companies such as DeepSeek, GLM, and Kimi by changing environment variables. Each company publishes a page on using its model with Claude Code, so the setup itself takes only a few lines. This article first summarizes each company's official setup examples and the reasons for doing this (benefits and drawbacks). It then looks closely at the costs, which are hard to follow. Comparing token prices alone leads to misreadings, because the bill also depends on how well the cache works, which model handles the background calls, and whether web search costs extra. DeepSeek begins charging for web search used from Claude Code on November 1, 2026. Based on the original texts of each company's and Anthropic's official documentation (checked October 19, 2026), this article covers the setup, how costs are determined, rough estimates for the same usage pattern, and precautions to avoid wasting money on the setup.
Unit price
"Other companies are cheaper" is not always true
For the same usage pattern, Kimi K3 is more expensive than Claude Sonnet 5.5, and Claude Haiku 5.5 comes out about the same as DeepSeek's cheap model.
From November 1
DeepSeek search becomes paid
$0.75 per 1,000 successful searches. The tokens used to summarize search results are billed separately.
Anthropic's position
Not officially supported
The official Claude Code documentation states that connecting to other companies' models is not a supported setup.
Contents
- 1. Benefits and drawbacks of using Claude Code
- 2. How it works and setup: replacing the endpoint and model names
- 3. Pricing by provider
- 4. How much the same usage costs: estimates for 9 models
- 5. Four things that change the bill
- 6. DeepSeek search billing (from November 1, 2026)
- 7. Choosing a fixed-price coding plan
- 8. Setup pitfalls to avoid losing money
- 9. Where your code goes and security
- Summary
- FAQ
1. Benefits and drawbacks of using Claude Code
Models from DeepSeek, GLM, and Kimi can also be used through each company's chat interface, API, or its own coding tools. Still, the reason to use them from Claude Code is that you keep the usability of Claude Code itself and only swap the model that answers.
This setup suits people who are used to Claude Code and want to keep costs down, or who often hit usage limits. Before you start, also check whether you are allowed to send your work code outside (Chapter 8).
2. How it works and setup: replacing the endpoint and model names
Claude Code sends requests in the same format as Anthropic's API. DeepSeek, Kimi (Moonshot AI), and GLM (Z.ai) each provide an endpoint that accepts this format (an Anthropic-compatible endpoint). If you change ANTHROPIC_BASE_URL to the company's endpoint and ANTHROPIC_AUTH_TOKEN to the company's API key, the model answering will be the other company's model, while the Claude Code interface stays the same.
Within a single task, Claude Code sends several calls that each serve a different role. Environment variables decide which model handles which call.
| Environment variable | What it decides |
|---|---|
ANTHROPIC_MODEL | The model used for the main conversation |
ANTHROPIC_DEFAULT_OPUS_MODEL and ANTHROPIC_DEFAULT_SONNET_MODEL | Where requests go when you choose opus or sonnet with /model |
ANTHROPIC_DEFAULT_HAIKU_MODEL | The model used when you choose haiku, and for background tasks such as summarizing the conversation and generating session names |
CLAUDE_CODE_SUBAGENT_MODEL | The model used by subagents |
Source: Model configuration and Environment variables (Claude Code official documentation, checked October 19, 2026). The former ANTHROPIC_SMALL_FAST_MODEL is treated as deprecated, and its successor is ANTHROPIC_DEFAULT_HAIKU_MODEL.
How far you configure affects both cost and behavior. The recommended values from each company are as follows.
| Provider | Endpoint (ANTHROPIC_BASE_URL) | Main, opus, and sonnet | haiku and subagents |
|---|---|---|---|
| DeepSeek | https://api.deepseek.com/anthropic | deepseek-flash (1M context) | deepseek-flash |
| Kimi (pay-as-you-go API) | https://api.moonshot.ai/anthropic | kimi-k3 (1M context) | haiku uses kimi-k2.7-code; subagents use kimi-k3 |
| GLM (Z.ai, Coding Plan steps) | https://api.z.ai/api/anthropic | GLM-5.3 or GLM-5.3-Flash | GLM-5.3-Flash |
Sources: Integrate with Claude Code (DeepSeek API Docs), Use Kimi in Claude Code (Kimi API Platform), and Claude Code (the GLM Coding Plan steps in the Z.ai developer documentation. The default-value column shows GLM-5.3-Flash for all three; the manual setup example shows GLM-5.3 for opus and sonnet. The setup example below is from the same page). All checked October 19, 2026. DeepSeek and Kimi also specify the thinking level (CLAUDE_CODE_EFFORT_LEVEL=max) and the length at which automatic summarization starts (CLAUDE_CODE_AUTO_COMPACT_WINDOW).
Official setup examples by provider
Below, the values from each company's page are shown in the form of the env section of ~/.claude/settings.json (checked October 19, 2026). Replace the key parts with your own keys. Values from each company may change, so check each company's page before use.
DeepSeek (DeepSeek's page uses export in the terminal. The values are the same)
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your DeepSeek API key",
"ANTHROPIC_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash",
"CLAUDE_CODE_SUBAGENT_MODEL": "deepseek-flash",
"CLAUDE_CODE_EFFORT_LEVEL": "max",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "786432"
}
}
GLM (manual setup example for the Z.ai GLM Coding Plan)
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "your Z.ai API key",
"ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3[1m]",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1,
"API_TIMEOUT_MS": "3000000"
}
}
Kimi (setup example for the pay-as-you-go Kimi API)
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.moonshot.ai/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your Kimi API key",
"ANTHROPIC_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "kimi-k3[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "kimi-k2.7-code",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "kimi-k3[1m]",
"CLAUDE_CODE_SUBAGENT_MODEL": "kimi-k3[1m]",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
"CLAUDE_CODE_EFFORT_LEVEL": "max"
}
}
After saving, restart Claude Code and use /status to confirm that the destination (Base URL) and the model have changed (following Kimi's page). Kimi's kimi-k2.7-code model cannot turn off thinking, so if thinking is left off, it returns a 400 error. Writing keys into settings.json leaves them in plain text in the file, so keep it out of Git (Chapter 8).
Anthropic does not support this setup. The official Claude Code documentation states that routing requests through any gateway to models other than Claude is not supported. It explains that ANTHROPIC_BASE_URL "changes where requests are sent, not which model answers." Behavior depends on how well each company implements compatibility, and for problems you will need to contact each company.
Sources: LLM gateways and Model configuration (Claude Code official documentation, checked October 19, 2026).
3. Pricing by provider
All of these companies charge pay-as-you-go based on the number of tokens used (for fixed-price plans, see Chapter 7). The per-million-token prices are listed below alongside Claude's current models. All amounts are in US dollars.
| Per 1 million tokens | Input | Input that hits cache | Output | Context length |
|---|---|---|---|---|
| DeepSeek deepseek-flash | $0.30 | $0.006 | $1.20 | 1M |
| DeepSeek deepseek-v4-pro | $1.32 | $0.044 | $3.96 | 1M |
| Kimi kimi-k3 | $3.00 | $0.30 | $15.00 | about 1M |
| Kimi kimi-k2.7-code | $0.95 | $0.19 | $4.00 | about 262K |
| GLM-5.3 | $1.40 | $0.26 | $4.40 | 1M |
| GLM-5.3-Flash | $0.15 | $0.03 | $0.50 | 1M |
| Claude Haiku 5.5 (prompts up to 100K tokens) | $0.10 | $0.01 | $0.50 | 1M |
| Claude Sonnet 5.5 | $2.00 | $0.10 | $10.00 | 1M |
| Claude Opus 5.5 | $4.00 | $0.20 | $20.00 | 1M |
Sources: Models & Pricing (DeepSeek API Docs), Model Inference Pricing (Kimi API Platform, excluding tax), Pricing (Z.ai developer documentation), and Pricing (Claude Platform official documentation). All checked October 19, 2026. DeepSeek prices shown are for peak hours (half price outside peak hours).
Four rules outside the table have a significant effect.
4. How much the same usage costs: estimates for 9 models
A price table alone makes it hard to see how big the differences are, so this chapter fixes one usage pattern and calculates from it. In Claude Code, earlier exchanges are added to the input again each time, so it is normal for most of the input to hit the cache and for output to be much smaller than input. The following amounts are assumed.
- Total input sent in one task (session): 2 million tokens (of which 90%, or 1.8 million tokens, hit the cache, and 200,000 tokens do not)
- Total output: 50,000 tokens
Calculation: (uncached input 0.2M × input price) + (cached input 1.8M × cache price) + (output 0.05M × output price). Prices are from the table in Chapter 3. For example, DeepSeek flash is 0.2 × 0.30 + 1.8 × 0.006 + 0.05 × 1.20 = about $0.13.
Three points can be drawn from this estimate.
- "The other company is cheaper" depends on which one. DeepSeek flash costs about one-eighth of Sonnet 5.5, but Kimi K3 costs about 70% more than Sonnet 5.5. GLM-5.3 is almost the same as Sonnet 5.5. Although GLM-5.3 has a lower price for regular input, Sonnet 5.5 is cheaper for cached input ($0.10 vs. $0.26), so the gap narrows in usage where 90% of input hits the cache.
- Claude also has the cheapest option. Claude Haiku 5.5 is cheaper than DeepSeek flash as long as each request is 100K tokens or less. However, long Claude Code conversations easily exceed 100K tokens, and above that threshold the cost rises to about $0.32.
- The same task does not produce the same number of tokens. Tokenizers (the systems that split text into tokens) differ by company, so the same text can count differently. Claude Haiku 5.5 also counts the same text about 30% higher than the previous generation. The length of answers and the number of back-and-forth exchanges needed to finish a task also vary by model. This estimate is an example for comparing unit prices, not a prediction of your bill.
5. Four things that change the bill
① How well the cache works
According to the table in Chapter 3, input that hits the cache costs one-fifth to one-fiftieth of input that misses it. How well the cache works is the biggest factor in Claude Code costs.
Claude Code sends requests with markers (cache_control) on the parts that may be cached. Anthropic's official documentation notes that if an intermediary drops these markers, no error occurs, but the entire conversation is billed as uncached input on every turn. How each company's endpoint handles these markers differs.
- DeepSeek: Ignores
cache_control. Instead, it automatically caches the portion that matches the beginning of a previous request on disk. DeepSeek says it works on a "best effort" basis and does not guarantee a hit. Cache entries disappear within a few hours to a few days after they stop being used. - Kimi (K3): Automatically caches the beginning portion that is sent repeatedly. Writing to the cache is billed separately ($3.00 for 5 minutes), and a hit costs $0.30.
- GLM: There is a price for cached input ($0.26), and cache storage is free for a limited period.
Sources: LLM gateway protocol (Claude Code official documentation), Using the Anthropic API and Context Caching (DeepSeek API Docs), Model Inference Pricing (Kimi API Platform), and Pricing (Z.ai). Checked October 19, 2026.
To see how much actually hit the cache, check the usage details in each company's dashboard. DeepSeek's API response also returns the number of hits (prompt_cache_hit_tokens) and misses (prompt_cache_miss_tokens).
② Which model handles background calls and subagents
Claude Code makes separate background calls for tasks such as summarizing the conversation and generating session names. Using subagents adds more of these calls. If you assign an expensive model to these, lowering the cost of the main model will not reduce the total much.
Pay attention to where unconfigured slots are routed. The official Claude Code documentation states that even when you set overrides, some background calls are still sent with built-in model names (claude-…). DeepSeek replaces names starting with claude-opus with the higher-priced v4-pro. If the opus slot is sent with a claude-opus name, that call is billed at v4-pro prices. Kimi states that if you set only some of the variables, processing for the unset slot fails without notice. Set all the variables each company lists.
Sources: Roll out an LLM gateway and Manage costs (Claude Code official documentation), Using the Anthropic API (DeepSeek), and Use Kimi in Claude Code (Kimi). Checked October 19, 2026.
③ Time of day
DeepSeek's pay-as-you-go pricing is half price outside peak hours. On weekdays, daytime in Japan (10:00 to 13:00 and 15:00 to 19:00) falls within peak hours. The GLM fixed-price plan (Chapter 7) also consumes credits at half the rate outside peak hours. Long tasks that are not urgent become cheaper when run at night or on weekends.
④ Web search and page fetching
Claude Code's WebSearch is a tool that uses Anthropic's server-side search mechanism. When you connect to another company's endpoint, who runs this search and how much it charges differs by company. DeepSeek states that it handles the search with its own service, and billing starts on November 1, 2026 (next chapter). Kimi and GLM do not describe in their official pages how they handle Claude Code's WebSearch (checked October 19, 2026).
WebFetch (page retrieval) works by having Claude Code fetch a page and then summarize its contents in a separate model call before passing the result to the main model. The tokens for this summary are also billed at the rate of the connected service.
Source: Tools reference (Claude Code official documentation, checked October 19, 2026).
6. DeepSeek search billing (from November 1, 2026)
DeepSeek offers a Search API, which uses its own search engine, and a Fetch API, which returns the contents of a page in Markdown. DeepSeek's pricing page and the Search & Fetch page state the following.
Sources: Search & Fetch, Models & Pricing, and Integrate with Claude Code (DeepSeek API Docs, checked October 19, 2026).
One call costs $0.00075. If a task involves 20 searches, that is $0.015, and 100 searches cost $0.075. In the Chapter 4 estimate, one session of deepseek-flash cost about $0.13, so in tasks with many searches, search fees can amount to 10 to 60% of token costs. The cheaper the model's unit price, the larger the share the search fees appear to take.
For tasks where you don't want to use Claude Code's WebSearch, you can deny this tool in Claude Code's permission settings. Denying it lowers the quality of answers to questions that need up-to-date information, so decide based on the content of the task.
7. Choosing a fixed-price coding plan
Some companies offer fixed-price plans intended for use with coding tools such as Claude Code, separate from pay-as-you-go pricing. The API key and endpoint may differ from pay-as-you-go, so check the plan's setup page before configuring.
GLM Coding Plan
Z.ai's GLM Coding Plan starts at $18 per month, and it states that it can be used with Claude Code, Codex, and others. The amount you can use is determined by credits that reset every 5 hours and every week.
| Plan | Credits per 5 hours | Credits per week |
|---|---|---|
| Lite | 2,000 | 10,000 |
| Pro | 12,000 | 60,000 |
| Max | 28,000 | 140,000 |
Source: GLM Coding Plan Overview (Z.ai developer documentation, checked October 19, 2026).
The consumption formula is "(input × 6.9 + cached input × 1.7 + output × 24) ÷ 10,000" (for GLM-5.3; for GLM-5.3-Flash, the factors are 2.3, 0.56, and 8). If you calculate the same single session as in Chapter 4 (200,000 uncached input, 1.8 million cached input, and 50,000 output tokens) with GLM-5.3, it comes to about 564 credits during peak hours. With Lite, that is about 17 sessions per week. Outside peak hours, consumption is half, so that is about 35 sessions.
Paying for the same 17 sessions with pay-as-you-go GLM-5.3 costs about $16.5 ($0.97 per session). If you use it four weeks a month, Lite at $18 per month is much cheaper. Conversely, if you only use it a few times a month, pay-as-you-go costs less.
Kimi Code and others
Separate from its pay-as-you-go API, Kimi publishes steps for using Claude Code with Kimi Code, a membership service. Its endpoint (https://api.kimi.ai/coding/) and API key are different from the pay-as-you-go API, and Kimi warns against mixing the two setups. These steps have you run a script that writes entries into Claude Code's configuration file (~/.claude.json) before the setup, so read what it changes before running it. MiniMax also publishes steps for using Claude Code with its fixed-price plan.
Sources: Claude Code (Kimi Code Docs) and Claude Code (MiniMax API Docs). Checked October 19, 2026.
8. Setup pitfalls to avoid losing money
ANTHROPIC_BASE_URL and not the destination's credentials (such as ANTHROPIC_AUTH_TOKEN), the saved claude.ai login is used as the credential and requests reach the new destination. When connecting to another company, always set its key together with the endpoint./usage (/cost is an alias) and in the status line are estimates that Claude Code calculates at Anthropic's list prices. Check actual charges for other companies' models in each company's dashboard.ANTHROPIC_BASE_URL points to anything other than api.anthropic.com, Remote Control (operating from a smartphone) and server-managed settings distributed by administrators stop working.~/.claude/settings.json, as in Kimi's steps, leaves them in plain text. Writing them to a project's .claude/settings.json may put them into the repository.settings.json take priority over variables with the same name set in the terminal (a note in Kimi's steps).Sources: LLM gateways, Manage costs, and Feature availability (Claude Code official documentation), and Use Kimi in Claude Code (Kimi). Checked October 19, 2026.
If Claude Code won't connect to another company's endpoint, see Fixing Claude Code connection errors (proxy and network), which explains how to check the destination and credentials. For how to run models on your own PC, see How to do coding with a local LLM.
9. Where your code goes and security
When you connect to another company's model, the files Claude Code reads, the results of commands it runs, and the contents of the conversation are sent to that company's servers. The decision you need to make before cost is which repositories you may send.
DeepSeek's data handling
Sources: DeepSeek Privacy Policy and DeepSeek Open Platform Terms of Service (checked October 19, 2026. When the privacy policy is opened from Japan, the Japanese version is displayed).
In Japan, the Personal Information Protection Commission issued "Information on DeepSeek" on February 3, 2025. It warns that data DeepSeek collects is stored on servers in the People's Republic of China, and that Chinese laws (including the Personal Information Protection Law, the Cybersecurity Law, the Data Security Law, and the National Intelligence Law) apply to that data. It does not prohibit private use.
Source: Information on DeepSeek (Personal Information Protection Commission, February 3, 2025, updated March 5).
In the United States, it was reported that on October 19, 2026, the Department of Homeland Security (DHS) issued an order requiring the removal of DeepSeek products, and third-party services that use DeepSeek, from the IT systems of federal civilian agencies, and barring their procurement. The reason given is that if government employees or business partners use them, sensitive data could flow to China. A list shows that the order is scheduled for publication in the Federal Register on October 20. At the time this article was written, we have not confirmed the text of the order or the scope of what it covers (reports differ on whether federal contracts are included).
Sources: US Moves to Bar DeepSeek From Federal Agencies and Contracts (Bloomberg, October 19, 2026), DeepSeek Blocked In US Federal Agencies (BankInfoSecurity), and a Federal Register listing of the scheduled publication.
Assessing the model's safety
For DeepSeek's current deepseek-flash (DeepSeek-V4.1-Flash-1017, released October 17, 2026), neither DeepSeek's own announcement nor its model card includes a safety evaluation. We could not find a third-party safety evaluation as of October 19, 2026. The weights are published under the MIT license, so if you run the model on your own machine, your code does not leave it. However, the weight files alone are about 510 GB, which is too large to run casually on a typical PC. The performance, pricing, and safety of this model are covered in detail in Explaining DeepSeek V4.1 Flash 1017.
Sources: DeepSeek-V4.1-Flash-1017 (DeepSeek API Docs) and DeepSeek-V4.1-Flash-1017 (Hugging Face model card). Checked October 19, 2026.
Kimi and GLM: the same checks apply
When using Kimi (Moonshot AI) and GLM (Z.ai), check where data is stored, whether it is used for training, and which law governs, using each company's privacy policy and API terms before you use them. This article did not examine the contents of the two companies' terms.
- Decide first whether sending is acceptable. Published open-source code and personal learning code are easy to test with. Work code, customer data, and repositories containing secrets (API keys and passwords) should not be sent until your employer gives permission.
- Don't keep secrets in the repository. Claude Code reads the files it needs for a task, so set permissions so that files holding secrets, such as
.env, cannot be read. - If in doubt, stay with Claude. If you want to lower costs without changing the destination, you can choose a cheaper model such as Claude Haiku 5.5 (Chapter 4).
Summary
- The advantage of using other models from Claude Code is that you keep the interface, tools, and settings and only change the model that answers. It serves as a way to lower costs and as a fallback when you hit Claude usage limits.
- DeepSeek, Kimi, and GLM offer Anthropic-compatible endpoints, so you can use them from Claude Code with
ANTHROPIC_BASE_URL, each company's key, and model-name environment variables. This is outside Anthropic's support. - In the estimate for the same usage pattern, DeepSeek flash, GLM-5.3-Flash, and Claude Haiku 5.5 are cheap, while Kimi K3 is more expensive than Claude Sonnet 5.5. GLM-5.3 is almost the same as Sonnet 5.5.
- Four things change the bill: how well the cache works, which model handles background calls and subagents, time of day, and web search.
- From November 1, 2026 (Beijing time), DeepSeek charges $0.75 per 1,000 successful Claude Code searches and fetches. The tokens for summarization are billed separately.
- If you use Claude Code heavily, a fixed-price plan such as the GLM Coding Plan may be cheaper. The Lite plan ($18 per month) covers roughly 17 to 35 sessions per week, based on the estimates.
- When you connect to another company, your code, command results, and conversations are sent to that company's servers. DeepSeek stores data in China and lists training as a purpose. Decide first whether your work code can be sent.
- Don't change the destination without setting a key. The amounts on screen are estimates at Anthropic's list prices, so check actual charges in each company's dashboard.
FAQ
Q. Can I use other companies' models with a Claude Pro or Max subscription?
A. No. You pay for other companies' models with their own API keys or fixed-price plans. According to the official Claude Code documentation, while another company's key is set, your claude.ai subscription allowance is not used for those requests.
Q. If I switch to another company's model, can I use all of Claude Code's features?
A. Some features will not work. Remote Control and server-managed settings from administrators stop when the destination is not Anthropic. Images, PDFs, and web search depend on how far each company's compatibility goes. For example, DeepSeek's compatible endpoint states that it does not support document inputs such as PDFs.
Q. Will searches I ran before November 1 be billed?
A. According to DeepSeek, calls made before 00:00 Beijing time on November 1, 2026 are free, and billing applies to each call from that point on.
Q. Which option is the cheapest overall?
A. It depends on your work and how you use it. On unit price alone, DeepSeek flash, GLM-5.3-Flash, and Claude Haiku 5.5 are the cheapest, but the number of tokens counted and the number of back-and-forth exchanges needed to finish a task differ by model. The most reliable approach is to run the same task once on two or three models and compare the actual amounts on each company's statements.
Sources
- Claude Code official documentation: LLM gateways, Roll out an LLM gateway, LLM gateway protocol, Model configuration, Environment variables
- Claude Code official documentation: Manage costs, Feature availability, Tools reference
- Claude Platform official documentation: Pricing
- DeepSeek API Docs: Models & Pricing, Search & Fetch, Using the Anthropic API, Context Caching, Integrate with Claude Code
- Kimi: Model Inference Pricing and Use Kimi in Claude Code (Kimi API Platform), Claude Code (Kimi Code Docs)
- Z.ai developer documentation: Pricing, GLM Coding Plan Overview, Claude Code
- MiniMax API Docs: Claude Code