Beta
Discord Download

How to use DeepSeek in Claude Code and Codex

AutoRouter7 min read

AutoRouter, the Mac app for Codex and Claude Code, puts DeepSeek V4.1 Flash 1017 in both apps' model pickers with no key or config, next to the ChatGPT and Claude plans you already pay for. The native route takes a DeepSeek key and config in each app. To use DeepSeek in Claude Code, set ANTHROPIC_BASE_URL to https://api.deepseek.com/anthropic, put a DeepSeek API key in ANTHROPIC_AUTH_TOKEN and point Claude Code's model variables at deepseek-flash, as DeepSeek's Claude Code guide shows. In Codex, add DeepSeek as a [model_providers.deepseek] table in ~/.codex/config.toml, plus a model catalog file (DeepSeek's Codex guide).

AutoRouter wrote this post. The direct routes below bill at DeepSeek's own prices with nothing in between. Every command is copied from DeepSeek's, Anthropic's or OpenAI's docs as checked on November 17, 2026; check the linked page before you paste.

How do you use DeepSeek in Claude Code?

Point Claude Code at DeepSeek's Anthropic-compatible endpoint with environment variables. Claude Code sends ANTHROPIC_AUTH_TOKEN as a bearer token to whatever ANTHROPIC_BASE_URL names (Anthropic docs), and DeepSeek's guide sets every model tier so the main session, background work and subagents all reach a model DeepSeek serves.

  1. Create an API key on the DeepSeek Platform and top up its balance.
  2. Run the exports below in your terminal (macOS and Linux), or add them to your shell profile to keep them.
  3. Start claude in your project from that same terminal.
  4. Run /status: the Anthropic base URL line should show https://api.deepseek.com/anthropic.
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

Two details from DeepSeek's guide matter for your bill. Model names that start with claude-opus are served by deepseek-v4-pro at the V4 Pro price, while claude-sonnet and claude-haiku names go to deepseek-flash. Web search works, and DeepSeek bills it as extra tokens plus its Search API fee.

While ANTHROPIC_AUTH_TOKEN is set, it replaces your claude.ai login: your Claude plan's limits don't apply to those requests, and they bill per token to the key's owner (Anthropic docs). Claude Code environment variables covers the other variables in that block.

How do you use DeepSeek in Codex?

Add DeepSeek as a custom provider in ~/.codex/config.toml. Codex only talks to providers through OpenAI's Responses API (responses is the only wire_api value, per OpenAI's config reference), and DeepSeek's endpoint at https://api.deepseek.com/ speaks it. The Codex CLI, the Codex app and the IDE extension all read the same file.

DeepSeek offers a setup script that asks which model to use (1 for deepseek-flash, 2 for deepseek-v4-pro, 9 to restore your old settings) and needs Codex 0.164 or later:

bash <(curl -fsSL https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.sh)

To set it up by hand, create the ~/.codex/models.json catalog from DeepSeek's guide (it describes both models' 1,048,576-token context and reasoning levels), then add this to config.toml:

model = "deepseek-flash"
model_provider = "deepseek"
preferred_auth_method = "apikey"
forced_login_method = "api"
model_reasoning_effort = "high"
show_raw_agent_reasoning = true
suppress_unstable_features_warning = true
model_catalog_json = "~/.codex/models.json"

[features]
standalone_web_search = true

[model_providers.deepseek]
name = "deepseek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
experimental_bearer_token = "<your DeepSeek API Key>"
supports_standalone_web_search = true

Restart Codex after the change. DeepSeek's guide notes that Codex groups session history by sign-in method, so your ChatGPT sessions are hidden while DeepSeek is configured. OpenAI's reference calls experimental_bearer_token discouraged and suggests env_key, which reads the key from an environment variable instead of the file. Codex model providers and config.toml, explained covers every provider key.

What does DeepSeek cost through its own API?

deepseek-flash costs $0.30 per million input tokens on a cache miss, $0.006 on a cache hit and $1.20 per million output tokens at peak hours, as of November 17, 2026 (DeepSeek pricing). Off-peak requests cost half. DeepSeek's peak hours are 01:00 to 04:00 and 06:00 to 10:00 UTC, Monday to Friday. Billing is pay as you go, deducted from a balance you top up.

The name deepseek-flash is served by DeepSeek-V4.1-Flash-1017, and DeepSeek still accepts the legacy name deepseek-v4-flash for the same model. deepseek-v4-pro (DeepSeek-V4-Pro-0813) costs $1.32 per million input tokens on a cache miss and $3.96 per million output tokens at peak. Both have a 1M-token context window.

How do you use DeepSeek with AutoRouter?

Pick it in the model picker. AutoRouter adds 20+ frontier and open-weight models to Codex and Claude Code with no keys or endpoints to set up, and DeepSeek V4.1 Flash 1017 is one of them on AutoRouter's models page as of November 17, 2026. Choosing it in the picker sends your requests straight to it. Choosing AutoRouter instead lets it work out how hard each task is and send the task to the model that fits, so hard work gets the strongest model your plans cover and quick work doesn't burn the plan.

  1. Download AutoRouter for macOS from autorouter.com.
  2. Open it, sign in or create a free account, sign in to your plans, allow Accessibility, and click Enable for each app.
  3. Start a new session and choose a model: in Codex, from the model menu under the message box; in Claude Code, with /model.

AutoRouter pools the plans you already pay for: connect Claude, ChatGPT, Grok and Gemini plans, and when one account reaches its limit, AutoRouter moves on to the account with the most room left before it spends any credit. Any of those plans can run in either app, so your Claude plan works inside Codex and your ChatGPT plan inside Claude Code. DeepSeek is a pay-per-use model on Pro, which costs $50 a month with $20 of included usage each month, at DeepSeek's price plus 10%. New accounts get Pro free for their first month, or until $20 of usage is spent, whichever comes first.

The trade-offs are real. A direct DeepSeek key costs about 10% less per token than DeepSeek through AutoRouter. AutoRouter runs on macOS 14 or later, and Claude Code needs Node 22.18 or later to use it. Requests pass through AutoRouter's servers on their way to DeepSeek; AutoRouter doesn't store transcripts, but keeps the message that opens each request, up to 4,000 characters, to review routing (AutoRouter privacy).

Which DeepSeek setup should you use?

Use DeepSeek's own endpoint if you want only DeepSeek at its lowest price, and AutoRouter if you want DeepSeek beside your plans in both apps without managing keys. As of November 17, 2026:

RouteSetupKeyWhat paysSwitching back
Claude Code + DeepSeek endpointNine environment variablesDeepSeek API keyYour DeepSeek balance, per tokenRemove the variables, open a new terminal
Codex + DeepSeek providerSetup script, or config.toml plus models.jsonDeepSeek API keyYour DeepSeek balance, per tokenScript option 9, or delete the added lines
AutoRouter (Mac)Install, sign in, click EnableNonePro usage at DeepSeek's price plus 10%; your plans for their own modelsPick another model, or disable the app in AutoRouter

For which tasks need which model once DeepSeek is in the picker, see Which model for which coding task. Try a new model in Codex or Claude Code without another API key covers the same setup for other providers.

Questions

Does my Claude plan pay for DeepSeek in Claude Code?

No. With ANTHROPIC_AUTH_TOKEN set, Claude Code sends your DeepSeek key in place of your claude.ai login, so the requests bill to your DeepSeek balance and your plan's limits don't apply (Anthropic docs). Unset the variables to go back to your plan.

Why did a DeepSeek request cost more than the Flash price?

Probably because Claude Code asked for an Opus model name. DeepSeek serves any name starting with claude-opus with deepseek-v4-pro at the V4 Pro price. Setting ANTHROPIC_DEFAULT_OPUS_MODEL to deepseek-flash[1m], as the guide does, keeps those requests on Flash.

Where did my ChatGPT sessions go in Codex?

Codex groups session history by sign-in method, so ChatGPT sessions are hidden while the DeepSeek provider is active. Run DeepSeek's setup script with option 9, or remove the lines you added to config.toml, then restart Codex to see them again.

How do I switch Claude Code back to Claude?

Delete the exports from your shell profile and open a new terminal. With no gateway credential set, Claude Code goes back to your saved claude.ai login (Anthropic docs). How to change the model in Claude Code covers /model and the model variables.

Sources