On this page
To use DeepSeek in Claude Code, set ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic and your DeepSeek key in ANTHROPIC_AUTH_TOKEN, then set the model variables to deepseek-flash. For Qwen, point it at https://router.huggingface.co with Qwen/Qwen3.8-27B. DeepSeek V4.1 Flash costs $0.30 in, $1.20 out per million tokens at peak. Boost is the flat-price pre-order for your other tools.
How it works
Claude Code talks to one address, set by ANTHROPIC_BASE_URL, and sends requests in Anthropic’s Messages format. Any host that accepts that format can answer. DeepSeek and Hugging Face both do, so you swap the address, the key and the model names, and Claude Code keeps working the way you know.
Know this before you start: Anthropic’s gateway docs say it “doesn’t support routing Claude Code to non-Claude models through any gateway.” It works, and DeepSeek and Hugging Face both publish setup guides for it, but support comes from them.
| Variable | What it does in Claude Code |
|---|---|
ANTHROPIC_BASE_URL |
The endpoint every request goes to |
ANTHROPIC_AUTH_TOKEN |
Your key, sent as Authorization: Bearer |
ANTHROPIC_MODEL |
The model the session starts on |
ANTHROPIC_DEFAULT_OPUS_MODEL, _SONNET_MODEL, _HAIKU_MODEL |
What the opus, sonnet and haiku aliases resolve to. Haiku also runs background tasks |
CLAUDE_CODE_SUBAGENT_MODEL |
The model subagents use |
Every variable is in Claude Code’s environment variables reference.
Which endpoint, and what it costs
| Model | Endpoint for Claude Code | Model name | Price per 1M (in / out) |
|---|---|---|---|
| DeepSeek V4.1 Flash | https://api.deepseek.com/anthropic |
deepseek-flash |
$0.30 / $1.20 peak, $0.15 / $0.60 off-peak |
| DeepSeek V4.1 Flash | https://router.huggingface.co |
deepseek-ai/DeepSeek-V4.1-Flash |
From $0.051 / $0.567, no added fee |
| Qwen3.8-27B | https://router.huggingface.co |
Qwen/Qwen3.8-27B |
From $0.04 / $1.35, no added fee |
| Qwen on Alibaba Cloud | See Model Studio’s Claude Code guide | Set per plan | Set per plan |
| Off Grid AI Boost | OpenAI-compatible, so not for Claude Code | Qwen 3.8, DeepSeek V4.1 Flash and more | Flat plan from $4.99 a month, usage worth twice the price |
Hugging Face charges each provider’s own rate with no markup. Its prices above are the lowest route; add :cheapest to the model name to ask for it.
Use DeepSeek in Claude Code
These are the exact settings from DeepSeek’s Claude Code guide.
- Get a key at platform.deepseek.com/api_keys.
- Set the variables. On Mac or Linux:
export ANTHROPIC_BASE_URL=https://api.deepseek.com/anthropic
export ANTHROPIC_AUTH_TOKEN=<your DeepSeek API Key>
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
export CLAUDE_CODE_EFFORT_LEVEL=max
export CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432
On Windows PowerShell, write each line as $env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic" and so on.
- Start it.
cdinto your project and runclaude.
The [1m] suffix asks Claude Code for a 1M-token context window, per its model configuration docs, which DeepSeek’s pricing page lists for deepseek-flash. Leave ANTHROPIC_DEFAULT_OPUS_MODEL on deepseek-flash: DeepSeek maps any model name that starts with claude-opus to deepseek-v4-pro, which bills at the higher V4 Pro price.
Use Qwen in Claude Code
Hugging Face’s router accepts Anthropic-format requests for every chat model it serves, per its Claude Code guide. That’s the simplest way to run Qwen3.8-27B in Claude Code.
- Create a token in your Hugging Face settings with the Make calls to Inference Providers permission.
- Set the variables, with Qwen in every model slot:
export HF_TOKEN="hf_..."
export ANTHROPIC_BASE_URL="https://router.huggingface.co"
export ANTHROPIC_AUTH_TOKEN="${HF_TOKEN}"
export ANTHROPIC_API_KEY="${HF_TOKEN}"
export ANTHROPIC_DEFAULT_OPUS_MODEL="Qwen/Qwen3.8-27B:cheapest"
export ANTHROPIC_DEFAULT_SONNET_MODEL="Qwen/Qwen3.8-27B:cheapest"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="Qwen/Qwen3.8-27B:cheapest"
export CLAUDE_CODE_SUBAGENT_MODEL="Qwen/Qwen3.8-27B:cheapest"
- Run
claude.
The same router serves DeepSeek: swap in deepseek-ai/DeepSeek-V4.1-Flash:cheapest. You can mix slots too, for example Qwen for Sonnet and DeepSeek for Haiku. Hugging Face also ships an hf claude command (hf extensions install hf-claude) that lets you pick the model from a list and launches Claude Code with these variables set.
Prefer Qwen from Alibaba directly? Model Studio’s Claude Code guide gives a .../apps/anthropic base URL for each of its plans. Use the key type that matches the URL you pick, because a mismatched pair fails.
Make it stick, and check it
Shell exports last for one terminal. To keep the settings, put them in the env block of ~/.claude/settings.json, as Claude Code’s gateway setup page shows:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.deepseek.com/anthropic",
"ANTHROPIC_AUTH_TOKEN": "your-deepseek-key",
"ANTHROPIC_MODEL": "deepseek-flash[1m]",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "deepseek-flash"
}
}
Don’t put the key in a project’s .claude/settings.json; that file gets committed. Then run /status inside Claude Code. The Anthropic base URL line should show your endpoint, and an Auth token line should name ANTHROPIC_AUTH_TOKEN.
What it costs in a month
A busy Claude Code day can send 3M tokens. Over 30 days that’s 90M tokens, say 67.5M in and 22.5M out.
- DeepSeek API, peak: 67.5 × $0.30 + 22.5 × $1.20 = $20.25 + $27.00 = $47.25
- DeepSeek API, all off-peak: 67.5 × $0.15 + 22.5 × $0.60 = $10.13 + $13.50 = $23.63
- Qwen3.8-27B on Hugging Face, lowest route: 67.5 × $0.04 + 22.5 × $1.35 = $2.70 + $30.38 = $33.08
Claude Code resends the same system prompt and files a lot, and DeepSeek charges $0.006 per million input tokens on a cache hit at peak. A session with mostly cached input costs well under the figures above. Every open-model price side by side is on the API price index.
Where Boost fits
Off Grid AI Boost gives you one OpenAI-compatible key for open models, with Qwen 3.8 and DeepSeek V4.1 Flash named, at a flat price: Starter $4.99, Pro $9.99 or Max $49.99 a month for cohort 1, half the regular price for as long as you stay. Each plan includes usage worth its full regular price every month. “We don’t keep your prompts or train on them.”
Claude Code needs an Anthropic-format endpoint, so use DeepSeek or Hugging Face there. Boost’s key goes into the tools that take an OpenAI base URL: Cline and Roo Code, Aider and Continue, and Cursor. Boost is a pre-order: your key and base URL arrive by email in January 2027, or you get all your money back.
Not working? Symptom, check, fix
| Symptom | Check | Fix |
|---|---|---|
| Claude Code asks you to log in | No key reached the session | Export ANTHROPIC_AUTH_TOKEN in the same shell, or put it in ~/.claude/settings.json |
/status shows no Anthropic base URL line |
The variable didn’t reach Claude Code | Start claude from the shell where you exported it, or use the settings file |
| 400 error naming the model | A model variable has a typo or a name the host doesn’t serve | Copy deepseek-flash or Qwen/Qwen3.8-27B exactly into every model variable |
| Your DeepSeek bill shows V4 Pro charges | A model name starts with claude-opus, which DeepSeek maps to deepseek-v4-pro |
Set ANTHROPIC_DEFAULT_OPUS_MODEL to deepseek-flash[1m] |
| 401 on Hugging Face | The token lacks the Inference Providers permission | Make a fine-grained token with Make calls to Inference Providers |
400 naming context_management or “Extra inputs are not permitted” |
The host rejects a field Claude Code sends | Set CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, per Claude Code’s troubleshooting table |
| An auth warning names two credential sources | A saved claude.ai login and your key are both active | Run /logout, or unset the variable you don’t want |
FAQ
Can Claude Code use DeepSeek?
Yes. DeepSeek serves an Anthropic-format endpoint at https://api.deepseek.com/anthropic. Set ANTHROPIC_BASE_URL to it, put your DeepSeek key in ANTHROPIC_AUTH_TOKEN, set the model variables to deepseek-flash, and run claude.
Can Claude Code use Qwen?
Yes, through any host that accepts Anthropic-format requests. Hugging Face’s router at https://router.huggingface.co does, so you can set the model variables to Qwen/Qwen3.8-27B. Alibaba Cloud Model Studio also documents a Claude Code setup for its Qwen models.
Does Anthropic support Claude Code with other models? No. Anthropic’s gateway docs say it doesn’t support routing Claude Code to non-Claude models. It works because DeepSeek and Hugging Face accept Claude Code’s requests, so they are the ones to ask when something breaks.
Can I point Claude Code at an OpenAI-compatible API? Not directly. Claude Code sends Anthropic-format requests, so the endpoint has to accept them. For an OpenAI-compatible key like Off Grid AI Boost, use Cline, Roo Code, Aider, Continue or Cursor.
What does DeepSeek in Claude Code cost a month? At 90M tokens a month, 3 input for every output, DeepSeek’s API costs $47.25 at peak prices or $23.63 off-peak. Cache hits on repeated input cut that further.
Want a fixed bill for the rest of your tools? Compare flat-rate APIs for open models.