DEV Community

Cover image for Run DeepSeek Inside Claude Code or Codex Without Replacing Your Workflow
Khasky
Khasky

Posted on

Run DeepSeek Inside Claude Code or Codex Without Replacing Your Workflow

Most people assume that trying DeepSeek for coding means installing another client. It does not: Claude Code and Codex both have a documented path to it, and the only thing that changes is which model answers. 🙂

Claude Code   -> direct, Anthropic-compatible endpoint
Codex CLI     -> official setup script, Responses API
OpenCode      -> /connect, then /models
Aider         -> OpenAI-compatible base URL
LiteLLM       -> one local endpoint, fallback and budget
Ollama        -> local models, no API at all
Enter fullscreen mode Exit fullscreen mode

Claude Code with DeepSeek behind it

For Claude Code:

$env:ANTHROPIC_BASE_URL="https://api.deepseek.com/anthropic"
$env:ANTHROPIC_AUTH_TOKEN="sk-YOUR_DEEPSEEK_KEY"
$env:ANTHROPIC_MODEL="deepseek-flash[1m]"

claude
Enter fullscreen mode Exit fullscreen mode

The published block goes further and maps the default model slots, the subagent model and the effort level to DeepSeek. Requests billed this way come off the DeepSeek API balance, and a Claude subscription is not touched by them. The variables belong to the terminal window you set them in, so going back to Anthropic is a new window rather than an undo.

Codex over the Responses API

irm https://cdn.deepseek.com/api-docs/codex-deepseek-setup-en.ps1 | iex

codex
Enter fullscreen mode Exit fullscreen mode

The script offers Flash or Pro, writes the model catalog Codex reads, sets the provider to DeepSeek and keeps a backup of the configuration it replaced. Downloading it and reading it first is the safer order, because it rewrites files you rely on. 🔧

OpenCode

OpenCode connects to DeepSeek from inside its own interface: /connect takes the key, /models picks Flash or Pro. The client itself costs nothing, so the API usage is the whole bill.

Aider

setx OPENAI_API_BASE "https://api.deepseek.com"
setx OPENAI_API_KEY "sk-YOUR_DEEPSEEK_KEY"

aider --model openai/deepseek-flash
Enter fullscreen mode Exit fullscreen mode

Aider works on the Git repository directly, and setx needs a terminal restart before the values are visible.

LiteLLM as one local endpoint

model_list:
  - model_name: deepseek-flash
    litellm_params:
      model: deepseek/deepseek-flash
      api_key: os.environ/DEEPSEEK_API_KEY
Enter fullscreen mode Exit fullscreen mode

Point Claude Code at the local endpoint with the proxy's master key and you get provider fallback, spend tracking and a budget in front of DeepSeek, Claude, GPT and Gemini at once.

Running locally with Ollama

ollama run deepseek-coder:6.7b
Enter fullscreen mode Exit fullscreen mode

On an 11 GB card, DeepSeek Coder 6.7B and the 7B and 8B R1 distills are realistic, and 14B runs in 4-bit with part of the load in RAM. A 671B model there is not worth attempting. 🐢

Why DeepSeek Flash instead of Claude Sonnet 5 or GPT-5.6 Terra?

DeepSeek publishes two rates per million tokens, and off-peak is half of peak:

Flash, off-peak   $0.15 input (cache miss)   $0.60 output
Flash, peak       $0.30 input (cache miss)   $1.20 output
Pro, off-peak     $0.66 input (cache miss)   $1.98 output
Pro, peak         $1.32 input (cache miss)   $3.96 output
Enter fullscreen mode Exit fullscreen mode

The standard rung at the two providers a coding CLI reaches for by default:

Claude Sonnet 5   $2 input    $10 output
GPT-5.6 Terra     $2 input    $12 output
Enter fullscreen mode Exit fullscreen mode
Flash vs Claude Sonnet 5   ~7-17x cheaper
Flash vs GPT-5.6 Terra     ~7-20x cheaper
Enter fullscreen mode Exit fullscreen mode

The low end of each range is peak input, the high end is off-peak output, so where a run lands depends on the hour it runs and on how much of it is output. This compares API rates against API rates, so a fixed monthly subscription is not directly comparable.

Flash is a strong default for:

  • repository exploration
  • tests
  • docs
  • boilerplate
  • routine refactors
  • CI fixes
  • subagent loops

I would still escalate to a frontier Claude or GPT model for:

  • ambiguous architecture
  • hard debugging
  • security review
  • risky migrations

Neither side is universally weaker, and the split is where each one is worth its price.

Privacy

Do not casually send API keys, .env files, production credentials or large database dumps to a cloud model. For confidential code, prefer local inference or a provider whose retention policy matches your requirements.

When Codex keeps calling the OpenAI endpoint

The interface says DeepSeek-Flash and the traffic still goes to the OpenAI Responses endpoint, with no OpenAI key in play. The model catalog changed and the provider section did not.

[model_providers.deepseek]
name = "deepseek"
base_url = "https://api.deepseek.com/"
wire_api = "responses"
experimental_bearer_token = "sk-YOUR_DEEPSEEK_API_KEY"
Enter fullscreen mode Exit fullscreen mode

Close Codex, ChatGPT Desktop and VS Code completely and open them again, because picking the model in a running window does not reload the provider.

The catalog and the provider are two different settings, and only one of them is what the traffic follows.

Reference links


Follow me for more on AI, LLMs, and Software Development:
@khasky — LinkedIn / Patreon / GitHub / Bluesky / Mastodon
@khaskydev — X / Threads / Instagram / Pinterest

Top comments (0)