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), and then looks closely at the costs, which are hard to follow. It is based on the original texts of each company's and Anthropic's official documentation (checked October 19, 2026; pricing and DeepSeek search checked November 29, 2026).
How to read the costs
- Unit price alone
- Comparing token prices alone leads to misreadings. The bill also depends on the following.
- Cache
- How well the cache works.
- Background calls
- Which model handles the background calls.
- Web search
- Whether it costs extra. DeepSeek stopped charging per call for web search used from Claude Code on November 18, 2026, and now bills the results as tokens.
- What 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 18
No separate charge for DeepSeek search
There is no per-call fee. The tokens for search results and their summaries are still charged.
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 pricing (no separate charge from November 18, 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).
What you replace
- Destination
- Change
ANTHROPIC_BASE_URLto the company's endpoint. - Key
- Change
ANTHROPIC_AUTH_TOKENto the company's API key. - Result
- The Claude Code interface stays the same, but the model answering is the other company's model.
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 |
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) | 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 |
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 (check dates are as given in the sources above). 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-k3[1m]",
"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
- How to check
- Restart Claude Code and use
/statusto confirm that the destination (Base URL) and the model have changed (following Kimi's page). - Kimi note
- Earlier instructions assigned kimi-k2.7-code to haiku. The K2 series is scheduled to be discontinued at the end of December 2026, so switch to kimi-k3.
- Handling keys
- Writing keys into
settings.jsonleaves 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.
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 |
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
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.
Caching by provider
- 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.
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. Set all the variables each company lists.
Unconfigured slots
- Claude Code
- The official 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.
③ Time of day
DeepSeek's pay-as-you-go pricing is half price outside peak hours. Peak hours are set in UTC, so check where they fall in your own time zone. 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.
How WebSearch is handled
- DeepSeek
- States that it handles the search with its own service. Since November 18, 2026, there is no separate search charge, only token costs (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.
6. DeepSeek search pricing (no separate charge from November 18, 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. The price of searching from Claude Code changed twice in November 2026.
The current cost of searching depends on how many tokens the results and summaries add to the context. The more searches a task makes, the more input tokens it uses, so check DeepSeek's usage details.
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 |
How credits are consumed
- Formula
- (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).
- Example estimate
- 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.
- Sessions on Lite
- 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. MiniMax also publishes steps for using Claude Code with its fixed-price plan.
Cautions for Kimi Code
- Endpoint and key
- 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. - Script
- These steps have you run a script that writes entries into Claude Code's configuration file (
~/.claude.json) before the setup. Read what it changes before running it.
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).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
Japan: Personal Information Protection Commission
- What it issued
- "Information on DeepSeek," issued on February 3, 2025.
- The warning
- Data DeepSeek collects is stored on servers in the People's Republic of China, and Chinese laws (including the Personal Information Protection Law, the Cybersecurity Law, the Data Security Law, and the National Intelligence Law) apply to that data.
- Private use
- It does not prohibit private use.
United States: Department of Homeland Security (DHS) order
- The order
- The Secretary of Homeland Security signed an order dated July 24, 2026 that targets DeepSeek (Exclusion and Removal Order #2026-01), and it was published in the Federal Register on October 20, 2026.
- Scope
- Federal civilian agencies. National security systems and similar systems are excluded.
- Requirements
- Exclude products from DeepSeek and its affiliates from procurement, and remove DeepSeek products, and third-party products and services built using DeepSeek, from IT systems.
- Exceptions
- Can be requested in writing within 60 days.
- Reasons
- Data is stored on servers in China, and if government employees or business partners use the products, sensitive information could flow to China, among others.
- Effect on the private sector
- The order does not prohibit use by private companies or individuals. It affects companies that deliver products incorporating DeepSeek for federal government work.
Assessing the model's safety
The current deepseek-flash (DeepSeek-V4.1-Flash-1017, released October 17, 2026)
- DeepSeek's announcement
- Neither DeepSeek's own announcement nor its model card includes a safety evaluation.
- Third-party evaluations
- We could not find a third-party safety evaluation as of October 19, 2026.
- Running it yourself
- 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.
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
- Advantage
- 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.
- How to connect
- 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. - Estimates
- 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.
- What changes the bill
- Four things: how well the cache works, which model handles background calls and subagents, time of day, and web search.
- DeepSeek search
- From November 18, 2026 (Beijing time), Claude Code searches and fetches have no per-call charge (DeepSeek had announced $0.75 per 1,000 successful calls from November 1). The tokens for search results and summarization are still billed.
- Fixed-price plans
- 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.
- Where data goes
- 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.
- Setup cautions
- 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, Max, or Ultra 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. Does using Claude Code search with DeepSeek cost extra now?
A. No. From 12:00 Beijing time on November 18, 2026, DeepSeek does not bill searches and fetches called by the model per call; it bills the returned results as tokens. Before that, DeepSeek had announced that, from 00:00 Beijing time on November 1, it would charge $0.75 per 1,000 successful calls.
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