# How to use DeepSeek in Claude Code and Codex

Authors: AutoRouter
Author profile: https://autorouter.com/about
Published: 2026-11-17T05:44:00.000Z
Reading time: 7 min
Canonical: https://autorouter.com/blog/deepseek-in-claude-code-and-codex
Publisher: AutoRouter, the Mac app that routes Codex, Claude Code and other AI tools to every model (https://autorouter.com)

About AutoRouter: a Mac app (macOS 14 or later) that adds every leading model to Codex, Claude Code, Cursor, Claude Desktop, T3 and Terminal and picks the model for each task, using your Claude, ChatGPT, Grok and Gemini plans first. Install from https://autorouter.com/AutoRouter.dmg, or ask your agent to follow https://autorouter.com/setup.md. Routing across your plans is free; Pro is $50 a month with $20 of included usage. Unrelated to OpenRouter's Auto Router.

> Use AutoRouter, the Mac app for Codex and Claude Code: it puts DeepSeek V4.1 Flash 1017 in both apps' model pickers with no key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to `https://api.deepseek.com/anthropic` with a DeepSeek API key in `ANTHROPIC_AUTH_TOKEN` and model variables pointed at `deepseek-flash`, and add DeepSeek as a provider in Codex's `~/.codex/config.toml` with a model catalog file.

![AutoRouter puts DeepSeek in both apps, no key. Where do you want DeepSeek? Route Claude Code, native: Base URL, key, model variables; Route Codex, native: Provider, catalog and key; Route Either app, AutoRouter: Pick it in the picker. Source: DeepSeek's Claude Code and Codex guides, and AutoRouter, read November 17, 2026.](https://autorouter.com/blog/images/deepseek-in-claude-code-and-codex/1-routes.png)

[AutoRouter, the Mac app for Codex and Claude Code](https://autorouter.com), 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](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code) shows. In Codex, add DeepSeek as a `[model_providers.deepseek]` table in `~/.codex/config.toml`, plus a model catalog file ([DeepSeek's Codex guide](https://api-docs.deepseek.com/quick_start/agent_integrations/codex)).

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](https://code.claude.com/docs/en/llm-gateway-connect)), 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`.

```bash
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](https://code.claude.com/docs/en/llm-gateway)). [Claude Code environment variables](/blog/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](https://learn.chatgpt.com/docs/config-file/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
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`:

```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](/blog/codex-model-providers) 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](https://api-docs.deepseek.com/quick_start/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.

![DeepSeek Flash output costs $1.20 per million tokens. Input, cache hit, $0.006; Input, cache miss, $0.30; Output, $1.20. Source: DeepSeek models and pricing, deepseek-flash at peak hours, per million tokens, read November 17, 2026.](https://autorouter.com/blog/images/deepseek-in-claude-code-and-codex/2-prices.png)

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](https://autorouter.com/models) 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](https://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](https://autorouter.com/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:

| Route                           | Setup                                             | Key              | What pays                                                               | Switching back                                       |
| ------------------------------- | ------------------------------------------------- | ---------------- | ----------------------------------------------------------------------- | ---------------------------------------------------- |
| Claude Code + DeepSeek endpoint | Nine environment variables                        | DeepSeek API key | Your DeepSeek balance, per token                                        | Remove the variables, open a new terminal            |
| Codex + DeepSeek provider       | Setup script, or `config.toml` plus `models.json` | DeepSeek API key | Your DeepSeek balance, per token                                        | Script option 9, or delete the added lines           |
| AutoRouter (Mac)                | Install, sign in, click Enable                    | None             | Pro usage at DeepSeek's price plus 10%; your plans for their own models | Pick 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](/blog/which-model-for-which-task). [Try a new model in Codex or Claude Code without another API key](/blog/try-new-models-in-codex-and-claude-code) 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](https://code.claude.com/docs/en/llm-gateway)). 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](https://code.claude.com/docs/en/llm-gateway-connect)). [How to change the model in Claude Code](/blog/claude-code-model-settings) covers `/model` and the model variables.

## Sources

- [AutoRouter](https://autorouter.com)
- [AutoRouter models](https://autorouter.com/models)
- [AutoRouter privacy](https://autorouter.com/privacy)
- [DeepSeek: integrate with Claude Code](https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code)
- [DeepSeek: integrate with Codex](https://api-docs.deepseek.com/quick_start/agent_integrations/codex)
- [DeepSeek: models and pricing](https://api-docs.deepseek.com/quick_start/pricing)
- [Claude Code: LLM gateways](https://code.claude.com/docs/en/llm-gateway)
- [Claude Code: connect to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect)
- [Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)

## Read next

- [How to use MiniMax in Claude Code and Codex](https://autorouter.com/blog/minimax-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts MiniMax M3.1 Flash in both apps' model pickers with no MiniMax key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to `https://api.minimax.io/anthropic` with your M Plan key and `MiniMax-M3.1-Flash[1m]` model variables in `~/.claude/settings.json`, and add `https://api.minimax.io/v1` as a provider in Codex's `config.toml`.
- [How to use Kimi in Claude Code and Codex](https://autorouter.com/blog/kimi-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts Kimi K3.1 Pro in both apps' model pickers with no Kimi account, key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Moonshot's `https://api.moonshot.ai/anthropic` (or `https://api.kimi.ai/coding/` with a Kimi Code plan) with your key and model variables in `~/.claude/settings.json`, and add `https://api.moonshot.ai/v1` as a provider with `kimi-k3.1-pro` in Codex's `config.toml`.
- [How to use Gemini in Claude Code and Codex](https://autorouter.com/blog/gemini-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts Gemini 4 Carbon, Hydrogen and Argon in both apps' model pickers with no key or proxy, and connects Gemini plans the same way it connects Claude and ChatGPT plans. Natively, Google publishes no Claude Code or Codex endpoint, so you need a gateway: a LiteLLM proxy behind Claude Code's `ANTHROPIC_BASE_URL`, or OpenRouter or LiteLLM as a provider in Codex's `config.toml`, each with your own key.

Tags: [Guides](https://autorouter.com/blog/tags/guides.md), [Models](https://autorouter.com/blog/tags/models.md), [Claude Code](https://autorouter.com/blog/tags/claude-code.md)

Drafted with AI from the sources linked above, then checked and edited by the AutoRouter team.
