<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Miles Sun</title>
    <description>The latest articles on DEV Community by Miles Sun (@sunsiyuan).</description>
    <link>https://dev.to/sunsiyuan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4280674%2Fc9fd310b-6d28-48f3-a0eb-f47991e71b4a.png</url>
      <title>DEV Community: Miles Sun</title>
      <link>https://dev.to/sunsiyuan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sunsiyuan"/>
    <language>en</language>
    <item>
      <title>Run Claude Code on DeepSeek V4</title>
      <dc:creator>Miles Sun</dc:creator>
      <pubDate>Thu, 03 Dec 2026 13:40:59 +0000</pubDate>
      <link>https://dev.to/sunsiyuan/run-claude-code-on-deepseek-v4-1p19</link>
      <guid>https://dev.to/sunsiyuan/run-claude-code-on-deepseek-v4-1p19</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Disclosure: I run HaryAI, one of the providers used below.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Claude Code talks to any backend that speaks Anthropic's Messages API. You point it somewhere else with a handful of environment variables, and it stops caring that the model behind them isn't Claude. DeepSeek publishes exactly that kind of endpoint, so you can run Claude Code on DeepSeek V4 without touching your Claude subscription at all.&lt;/p&gt;

&lt;p&gt;Below is the setup against DeepSeek's own API, the one gotcha its guide doesn't mention, and, at the end, the same setup through HaryAI, a gateway I run that resells the same models at a discount.&lt;/p&gt;

&lt;h2&gt;
  
  
  The models
&lt;/h2&gt;

&lt;p&gt;DeepSeek currently serves two models behind this endpoint:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Model&lt;/th&gt;
&lt;th&gt;Model ID&lt;/th&gt;
&lt;th&gt;Served by&lt;/th&gt;
&lt;th&gt;Context&lt;/th&gt;
&lt;th&gt;Max output&lt;/th&gt;
&lt;th&gt;Image input&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;DeepSeek V4.1 Flash&lt;/td&gt;
&lt;td&gt;&lt;code&gt;deepseek-flash&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;DeepSeek-V4.1-Flash-1017&lt;/td&gt;
&lt;td&gt;1,048,576 tokens&lt;/td&gt;
&lt;td&gt;384,000 tokens&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DeepSeek V4 Pro&lt;/td&gt;
&lt;td&gt;&lt;code&gt;deepseek-v4-pro&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;DeepSeek-V4-Pro-0813&lt;/td&gt;
&lt;td&gt;1,048,576 tokens&lt;/td&gt;
&lt;td&gt;384,000 tokens&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;code&gt;deepseek-flash&lt;/code&gt; and &lt;code&gt;deepseek-v4-pro&lt;/code&gt; are the model IDs DeepSeek itself publishes for its API, not a label some wrapper invented. Flash is the one to default to: it reads images, and it's built for everyday text and code work. Pro is for harder reasoning and review, text only.&lt;/p&gt;

&lt;p&gt;(An older ID, &lt;code&gt;deepseek-v4-flash&lt;/code&gt;, is accepted on the same endpoint for compatibility; DeepSeek now serves it with V4.1 Flash and bills it at the Flash price.)&lt;/p&gt;

&lt;h2&gt;
  
  
  Point Claude Code at DeepSeek
&lt;/h2&gt;

&lt;p&gt;Claude Code's CLI and VS Code extension both read &lt;code&gt;~/.claude/settings.json&lt;/code&gt;. Back it up first, then add this to its &lt;code&gt;env&lt;/code&gt; block (create the file with &lt;code&gt;{}&lt;/code&gt; if it doesn't exist yet):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_BASE_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.deepseek.com/anthropic"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_AUTH_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;your DeepSeek API key&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_OPUS_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_SONNET_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_HAIKU_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_SUBAGENT_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_EFFORT_LEVEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"max"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_AUTO_COMPACT_WINDOW"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"786432"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the file already has an &lt;code&gt;env&lt;/code&gt; block, add these entries to it and leave the rest alone. Start a new Claude Code session and send it a short message to confirm it answers.&lt;/p&gt;

&lt;p&gt;What each entry does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;ANTHROPIC_BASE_URL&lt;/code&gt; sends Claude Code's requests to DeepSeek instead of Anthropic.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt; is your DeepSeek key. No Claude account is involved.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt; is the main model: V4.1 Flash with its full 1M-token context. The &lt;code&gt;[1m]&lt;/code&gt; suffix is what tells Claude Code this model has that context window.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/code&gt; and &lt;code&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/code&gt; catch every place Claude Code would otherwise reach for Opus or Sonnet, so those also run on DeepSeek.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/code&gt; covers small background jobs, like naming a session.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CLAUDE_CODE_SUBAGENT_MODEL&lt;/code&gt; puts subagents on DeepSeek too.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CLAUDE_CODE_EFFORT_LEVEL=max&lt;/code&gt; makes it think as hard as it can on every task.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;CLAUDE_CODE_AUTO_COMPACT_WINDOW=786432&lt;/code&gt; delays the conversation summary until you're near 768K tokens instead of the default 200K, since you actually have the room now.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The gotcha: the Artifact tool
&lt;/h2&gt;

&lt;p&gt;Add only the block above and your first request can fail with a 400, no matter which model you pick. The cause is Claude Code's Artifact tool: it's included in the tool list Claude Code sends on every request by default, and DeepSeek's endpoint rejects that tool definition outright. This isn't something DeepSeek's own integration guide mentions.&lt;/p&gt;

&lt;p&gt;The fix is one more setting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"CLAUDE_CODE_DISABLE_ARTIFACT"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add it to the same &lt;code&gt;env&lt;/code&gt; block and start a new session.&lt;/p&gt;

&lt;h2&gt;
  
  
  Switching to V4 Pro
&lt;/h2&gt;

&lt;p&gt;Change &lt;code&gt;deepseek-flash&lt;/code&gt; to &lt;code&gt;deepseek-v4-pro&lt;/code&gt; in the three main model entries (&lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt;, &lt;code&gt;ANTHROPIC_DEFAULT_OPUS_MODEL&lt;/code&gt;, &lt;code&gt;ANTHROPIC_DEFAULT_SONNET_MODEL&lt;/code&gt;) and keep the &lt;code&gt;[1m]&lt;/code&gt; suffix. Pro reads text only, so anything you paste as a screenshot gets skipped rather than read.&lt;/p&gt;

&lt;h2&gt;
  
  
  Undoing it
&lt;/h2&gt;

&lt;p&gt;Restore the &lt;code&gt;.bak&lt;/code&gt; copy of &lt;code&gt;~/.claude/settings.json&lt;/code&gt;, or delete the entries you added from its &lt;code&gt;env&lt;/code&gt; block, then start a new session. Your projects and sessions aren't touched either way, since nothing else in the file changes.&lt;/p&gt;

&lt;p&gt;One thing that stays odd either way: Claude Code's UI keeps showing "Opus," "Sonnet" and "Haiku" as model names. Those are Claude Code's own labels for its internal roles, not a claim about which model answers. With this setup, every one of them is DeepSeek.&lt;/p&gt;

&lt;h2&gt;
  
  
  Running the same setup through HaryAI
&lt;/h2&gt;

&lt;p&gt;Everything above works unchanged if you swap two values: the base URL and the key.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;"env"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_BASE_URL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"https://api.haryai.com"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_AUTH_TOKEN"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&amp;lt;your HaryAI key&amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_OPUS_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_SONNET_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash[1m]"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"ANTHROPIC_DEFAULT_HAIKU_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_SUBAGENT_MODEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"deepseek-flash"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_EFFORT_LEVEL"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"max"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_AUTO_COMPACT_WINDOW"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"786432"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nl"&gt;"CLAUDE_CODE_DISABLE_ARTIFACT"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"1"&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The model IDs are the same, because HaryAI is a gateway in front of DeepSeek (and other models), not a separate catalog with its own names. The reason to point here instead of at DeepSeek directly is price: HaryAI bills input and output at 45% of DeepSeek's peak list price around the clock, so it's 55% off during DeepSeek's peak hours and about 10% off during its off-peak hours. The &lt;code&gt;CLAUDE_CODE_DISABLE_ARTIFACT&lt;/code&gt; fix applies here too, for the same reason.&lt;/p&gt;

&lt;p&gt;If you'd rather not hand-edit JSON, &lt;a href="https://github.com/farion1231/cc-switch" rel="noopener noreferrer"&gt;CC Switch&lt;/a&gt; is a free app, installed from its GitHub releases page, that can import a provider's settings into Claude Code for you.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQ
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Why does Claude Code still list Opus, Sonnet and Haiku?&lt;/strong&gt;&lt;br&gt;
Those are Claude Code's own labels. With either setup above, every one of them runs on DeepSeek.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do my projects and sessions stay?&lt;/strong&gt;&lt;br&gt;
Yes. Only the &lt;code&gt;env&lt;/code&gt; entries change; everything else in your setup stays as it is.&lt;/p&gt;

&lt;p&gt;Sources: &lt;a href="https://api-docs.deepseek.com/quick_start/agent_integrations/claude_code" rel="noopener noreferrer"&gt;DeepSeek API Docs: Integrate with Claude Code&lt;/a&gt;, &lt;a href="https://api-docs.deepseek.com/quick_start/pricing" rel="noopener noreferrer"&gt;DeepSeek API Docs: Models &amp;amp; Pricing&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;More on this setup: &lt;a href="https://haryai.com/en/deepseek-claude-code" rel="noopener noreferrer"&gt;https://haryai.com/en/deepseek-claude-code&lt;/a&gt;&lt;/p&gt;

</description>
      <category>claudecode</category>
      <category>deepseek</category>
      <category>ai</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
