Use Claude Code with DeepSeek Flash or Pro: Setup, Checks, and Costs
A complete guide to connecting Claude Code to DeepSeek, choosing Flash or Pro, validating the route, troubleshooting errors, and comparing current DeepSeek and BetterToken prices.
Contents

You can point Claude Code directly at DeepSeek’s Anthropic-compatible endpoint without adding a proxy. For most coding work, start with the current official deepseek-flash[1m] profile; switch only the main agent to deepseek-v4-pro when a difficult refactor, architecture decision, or long debugging chain justifies the higher price.
Two details prevent misleading results. DeepSeek’s current all-Flash example overrides its automatic Claude-name mapping, and an unsupported model name silently falls back to deepseek-flash. A normal answer therefore proves connectivity, not that Pro actually handled the request.
Choose the model profile before changing any settings
As of September 27, 2026, DeepSeek’s Claude Code guide uses a cost-first, all-Flash profile. The separate Anthropic compatibility guide says names beginning with claude-opus map to deepseek-v4-pro, while names beginning with claude-sonnet or claude-haiku map to deepseek-flash.
| Profile | Main model / Opus | Sonnet | Haiku and subagents | Best fit |
|---|---|---|---|---|
| Official default, speed first | deepseek-flash[1m] | deepseek-flash[1m] | deepseek-flash | Daily coding, repository reading, many small tasks |
| Pro main thread | deepseek-v4-pro | deepseek-flash[1m] | deepseek-flash | Architecture, hard refactors, high-value diagnosis |
| Automatic Claude-name mapping | claude-opus* → deepseek-v4-pro | claude-sonnet* → deepseek-flash | claude-haiku* → deepseek-flash | Only when you know which Claude name the client is sending |
Explicit environment variables take precedence over automatic mapping. In other words, once the official example sets ANTHROPIC_DEFAULT_OPUS_MODEL to deepseek-flash[1m], an Opus selection still goes to Flash.
1. Install Claude Code and separate local issues from API issues
Install Node.js 18 or newer. Windows also needs Git for Windows. Check the CLI version before configuring the provider so an installation failure is not mistaken for an endpoint failure.
npm install -g @anthropic-ai/claude-code
claude --version
IFS= read -rs ANTHROPIC_AUTH_TOKEN
export ANTHROPIC_AUTH_TOKEN
export 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"
export CLAUDE_CODE_EFFORT_LEVEL="max"
export CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"
IFS= read -rs ANTHROPIC_AUTH_TOKEN waits for you to paste the DeepSeek API key without displaying it. Press Enter, then the next line exports it to the current shell. Do not place a real key in a command, script, shell history, or repository.
On Windows PowerShell, read the key securely and expose it only to the current process:
npm install -g @anthropic-ai/claude-code
claude --version
$secure = Read-Host -AsSecureString
$ptr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($secure)
try {
$env:ANTHROPIC_AUTH_TOKEN = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($ptr)
} finally {
[Runtime.InteropServices.Marshal]::ZeroFreeBSTR($ptr)
}
$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash"
$env:CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash"
$env:CLAUDE_CODE_EFFORT_LEVEL="max"
$env:CLAUDE_CODE_AUTO_COMPACT_WINDOW="786432"
These variables apply to Claude Code launched from that terminal. Once a temporary session works, you can decide whether to store the non-secret settings in a protected shell profile or Claude Code settings file; keep the key in an appropriate secret store.
2. Use Pro for the main thread without paying Pro rates for every subtask
The current models and pricing page lists the exact Pro model ID as deepseek-v4-pro, currently DeepSeek-V4-Pro-0813. The current Claude Code page demonstrates the [1m] suffix only for Flash, not for Pro, so the safer configuration uses the exact model-table ID instead of inventing deepseek-v4-pro[1m].
export ANTHROPIC_MODEL="deepseek-v4-pro"
export ANTHROPIC_DEFAULT_OPUS_MODEL="deepseek-v4-pro"
export ANTHROPIC_DEFAULT_SONNET_MODEL="deepseek-flash[1m]"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="deepseek-flash"
export CLAUDE_CODE_SUBAGENT_MODEL="deepseek-flash"
This sends the main session and the Opus route to Pro while keeping Sonnet, Haiku, and subagents on Flash. Repository scans, searches, and small delegated edits can otherwise multiply the Pro bill without improving the part of the task that actually needs deeper reasoning.
What the [1m] suffix does—and what it does not do
DeepSeek’s current documentation does not define [1m] in a separate sentence. It does show the suffix on the main Flash model and the Opus/Sonnet overrides, leaves Haiku and CLAUDE_CODE_SUBAGENT_MODEL as plain deepseek-flash, and lists a 1M context length in the model table. Taken together, the safest reading is to treat [1m] as Claude Code notation for requesting the million-token context route only where the integration guide shows it—not as a new model, a new price, or one million output tokens.
Keep three limits in view:
- The model table lists a maximum output of 384K, not 1M.
- The example sets
CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432, leaving headroom before the context ceiling. - Billing tables use
deepseek-flashanddeepseek-v4-proas model IDs. Do not append the suffix to an ID that the current integration page does not show.
3. Run a small validation before a long coding session
Start Claude Code inside a disposable or low-risk project:
test -n "${ANTHROPIC_AUTH_TOKEN:-}"
test "$ANTHROPIC_BASE_URL" = "https://api.deepseek.com/anthropic"
claude --version
cd /path/to/your/project
claude
Ask for an observable, read-only task such as: “Read package.json or pyproject.toml, list the available scripts, and do not edit files.” The success signal is a normal response plus a completed file-read tool call, with no 401, 402, 429, connection, or model error. The interaction is synchronous, so there is no job ID to poll; the result appears in the current session.
If Claude Code fails, isolate the endpoint from the client with the documented Anthropic SDK pattern and save the response:
python3 -m pip install anthropic
python3 - <<'PY'
import os
from pathlib import Path
import anthropic
client = anthropic.Anthropic(
base_url=os.environ["ANTHROPIC_BASE_URL"],
api_key=os.environ["ANTHROPIC_AUTH_TOKEN"],
)
message = client.messages.create(
model="deepseek-flash",
max_tokens=200,
messages=[{"role": "user", "content": "Reply with: endpoint OK"}],
)
text = "\n".join(block.text for block in message.content if block.type == "text")
Path("deepseek-smoke.txt").write_text(text, encoding="utf-8")
print("saved deepseek-smoke.txt")
PY
If deepseek-smoke.txt is created but Claude Code still fails, inspect Claude Code’s environment, conflicting settings, and restart state. If both paths fail, check the Base URL, key, balance, and provider status first.
DeepSeek explicitly states that unsupported model names fall back to deepseek-flash. The SDK check proves transport, while the read-only Claude Code task also checks one basic tool call; neither proves model identity. Before benchmarking Pro or forecasting Pro spend, inspect whatever request, usage, or billing detail the provider exposes. If it does not reveal the model, do not treat a successful response as proof that Pro was used.
Tools, thinking, and web search are compatible only within documented limits
Anthropic Messages compatibility covers the core request and tool structures, but it does not make DeepSeek behavior identical to Claude. The most relevant entries in DeepSeek’s compatibility table are:
| Capability | Current status | Practical consequence |
|---|---|---|
tools, tool_use, tool_result | Core fields supported | Normal local file and command tools have the required protocol foundation |
tool_choice | Supported; disable_parallel_tool_use ignored | Do not rely on that flag to force strictly serial tools |
| Web Search in Claude Code | Natively supported | Search summarization creates extra LLM requests and token charges |
Anthropic cache_control | Ignored | Do not infer actual cache hits from Anthropic cache directives |
| Thinking | Supported; budget_tokens ignored, effort supported | The current setup uses CLAUDE_CODE_EFFORT_LEVEL=max; Claude’s budget field is not a spend control here |
Document and search_result input blocks | Not supported | Validate workflows that depend on those content blocks before committing work |
code_execution_tool_result and mcp_tool_use blocks | Not supported | Server-side code-execution and Anthropic-specific MCP blocks are not equivalent |
tool_result.is_error | Ignored | Custom middleware should not depend on that field alone to convey failure |
DeepSeek’s Claude Code guide says its API can provide Claude Code’s Web Search tool. When the model decides to search, additional LLM calls summarize retrieved material, so web search must be included in cost estimates along with retries and long-context turns.
Troubleshoot by symptom, then repeat the same short test
| Symptom | Check first | Fix and retest |
|---|---|---|
| 401 / authentication failure | Wrong key, whitespace, or key missing from this shell | Re-enter it with hidden input, restart Claude Code, and repeat the read-only task |
| 402 / insufficient balance | DeepSeek account balance | Top up, then retry the same short request rather than a long agent run |
| 400 / 422 | Invalid field, model ID, or middleware rewrite | Restore the official variables; a custom Thinking + tools client must return every prior reasoning_content block |
| 429 | Request rate and parallel sessions | Reduce concurrency and retry with backoff |
| 500 / 503 | Provider error or overload | Wait briefly, retry, and record the time if it persists |
| Response works but does not look like Pro | Typo or unsupported-name fallback | Use exact deepseek-v4-pro and confirm the provider-side model/billing category |
| Settings appear unchanged | Old process or another settings layer overrides the shell | Quit every Claude Code process, open a new terminal, set variables again, and relaunch |
| Web search does not trigger | The model may have judged search unnecessary | Ask explicitly for current web information; lack of search alone is not a connection failure |
The official DeepSeek error-code page assigns distinct causes to 401, 402, 429, 500, and 503. Change one variable at a time and rerun the same small task; otherwise you cannot tell which change fixed the route.
DeepSeek vs BetterToken prices verified on September 27, 2026
All figures below are USD per 1 million tokens. DeepSeek uses peak and off-peak tiers; BetterToken publishes a catalog price without the same time-of-day split. Prices and versions can change, so recheck the DeepSeek pricing page and the single BetterToken pricing page before a large run.
Official DeepSeek pricing
| Model ID / current version | Tier | Cache-miss input | Cache-hit input | Output |
|---|---|---|---|---|
deepseek-flash / DeepSeek-V4.1-Flash | Off-peak | $0.15 | $0.003 | $0.60 |
deepseek-flash / DeepSeek-V4.1-Flash | Peak | $0.30 | $0.006 | $1.20 |
deepseek-v4-pro / DeepSeek-V4-Pro-0813 | Off-peak | $0.66 | $0.022 | $1.98 |
deepseek-v4-pro / DeepSeek-V4-Pro-0813 | Peak | $1.32 | $0.044 | $3.96 |
Peak hours are 01:00–04:00 and 06:00–10:00 UTC, Monday through Friday, excluding Chinese public holidays; all other hours are off-peak. The September 10 change log says deepseek-flash now calls V4.1 Flash and legacy deepseek-v4-flash names are temporarily routed to it.
BetterToken public catalog pricing
| BetterToken model ID / current mapping | Catalog endpoint types | Input | Cache hit | Output |
|---|---|---|---|---|
deepseek-flash / latest Flash, currently V4.1 Flash | Anthropic, OpenAI | $0.132 | $0.00264 | $0.528 |
deepseek-pro / latest Pro, currently V4-Pro-0813 | OpenAI | $0.5808 | $0.01936 | $1.7424 |
deepseek-v4-pro-0813 / V4-Pro-0813 | Anthropic, OpenAI | $0.5896 | $0.0176 | $1.7644 |
deepseek-pro is slightly cheaper in the catalog, but it is listed only for the OpenAI endpoint. Similar names or prices do not make it valid for Claude Code’s Anthropic Messages route. For Pro through BetterToken, the catalog entry to validate is deepseek-v4-pro-0813, which explicitly includes Anthropic support.
For a concrete comparison, assume 1 million cache-miss input tokens and 200,000 output tokens, with no cache benefit, web-search calls, or retries:
- Flash: about $0.27 on DeepSeek off-peak, $0.54 at peak, and $0.2376 at the BetterToken catalog rate.
- Pro: about $1.056 on DeepSeek off-peak, $2.112 at peak, and $0.9425 with BetterToken’s Anthropic-capable Pro ID.
Those figures describe the catalog snapshot on September 27, 2026. They are not a promise that BetterToken is cheaper on every date or invoice. Context size, tool loops, searches, retries, and provider price changes all affect the final cost.
Optional: evaluate a BetterToken route without guessing the mapping
BetterToken’s public catalog marks deepseek-flash and deepseek-v4-pro-0813 as Anthropic-capable, while deepseek-pro is OpenAI-only. That is enough to compare prices and identify candidate IDs, but it is not enough to publish a confirmed Claude Code model mapping.
The current BetterToken Claude Code guide documents https://bettertoken.ai without /v1, authentication, restart behavior, and mappings for Claude, Kimi, and GLM. It does not provide a DeepSeek-specific Claude Code profile. It also tells Claude-provider users not to set ANTHROPIC_MODEL or ANTHROPIC_DEFAULT_*_MODEL manually. Do not infer and persist a DeepSeek mapping from the price catalog alone.
If BetterToken’s current Setup dialog or newer documentation exposes a DeepSeek profile, use the exact model ID it displays and repeat the read-only task plus SDK smoke test from the previous section. For Pro, only consider the Anthropic-capable deepseek-v4-pro-0813; do not substitute the OpenAI-only deepseek-pro. Until a DeepSeek-specific mapping is documented or confirmed in your account, the direct DeepSeek endpoint above is the known configuration.
When you are ready to evaluate that route, review the current prices, then create an account and API key.
Pick the route that matches the task
- Most coding work: use the direct DeepSeek endpoint with
deepseek-flash[1m]. It matches the current official default and keeps iterative work inexpensive. - Difficult, high-value work: put only the main thread and Opus route on
deepseek-v4-pro; keep Sonnet, Haiku, and subagents on Flash. Confirm that no fallback occurred before scaling usage. - One balance or multi-provider routing: evaluate BetterToken only when the current Setup exposes a DeepSeek profile. Treat
supported_endpoint_typesas a candidate filter, then verify the actual mapping, exact ID, and same-day price. - Claude-specific content blocks or behavioral parity: use a Claude model. Transport compatibility proves that selected fields can be exchanged; it does not prove identical model behavior or complete tool parity.
Before using the setup on an important repository, close the loop: the CLI version is visible, the key never appears on screen, the Base URL is exact, a read-only task succeeds, and model identity is either confirmed from available records or explicitly left unconfirmed. That makes later model-alias, mapping, and price changes much easier to diagnose.