<?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: XHuoAPI</title>
    <description>The latest articles on DEV Community by XHuoAPI (@xhuoapi).</description>
    <link>https://dev.to/xhuoapi</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%2F4176341%2F7500cace-4a4e-4e70-80fa-ccbdc7f21627.png</url>
      <title>DEV Community: XHuoAPI</title>
      <link>https://dev.to/xhuoapi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/xhuoapi"/>
    <language>en</language>
    <item>
      <title>Running Claude Code on DeepSeek, GLM and Qwen with two environment variables</title>
      <dc:creator>XHuoAPI</dc:creator>
      <pubDate>Sun, 11 Oct 2026 06:09:07 +0000</pubDate>
      <link>https://dev.to/xhuoapi/running-claude-code-on-deepseek-glm-and-qwen-with-two-environment-variables-3pif</link>
      <guid>https://dev.to/xhuoapi/running-claude-code-on-deepseek-glm-and-qwen-with-two-environment-variables-3pif</guid>
      <description>&lt;p&gt;Claude Code talks to its backend in the Anthropic Messages format. Any endpoint that accepts that format can stand in for Anthropic's API, which means you can run the same agent loop on DeepSeek, GLM, Qwen or Kimi without a proxy or a converter.&lt;/p&gt;

&lt;p&gt;I tested this on Claude Code 2.1.284 by asking it to create and write a real file with each model, and re-ran the DeepSeek case on 2.1.296 today. Here is the setup and what I found.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Disclosure: I run XHuoAPI, the gateway used below. The same two variables work with any Anthropic-compatible endpoint.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setup
&lt;/h2&gt;

&lt;p&gt;Install Claude Code (Node.js 18+):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt; @anthropic-ai/claude-code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Point it at the gateway. Leave &lt;code&gt;/v1&lt;/code&gt; off the base URL; Claude Code appends &lt;code&gt;/v1/messages&lt;/code&gt; itself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;https://api.xhuoapi.ai
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;YOUR_KEY
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;deepseek-v3.2
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;deepseek-v3.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or put the same values in the &lt;code&gt;env&lt;/code&gt; block of &lt;code&gt;~/.claude/settings.json&lt;/code&gt; if you'd rather not touch your shell config.&lt;/p&gt;

&lt;p&gt;Check the connection with a one-off task:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;claude &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="s2"&gt;"Reply with the single word: ok"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Switching models
&lt;/h2&gt;

&lt;p&gt;Change &lt;code&gt;ANTHROPIC_MODEL&lt;/code&gt; and &lt;code&gt;ANTHROPIC_DEFAULT_HAIKU_MODEL&lt;/code&gt; together. The second one matters: Claude Code sends some background work to a "Haiku-class" model, and if that variable still points at a model your endpoint doesn't serve, those background calls fail quietly.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happened in the test
&lt;/h2&gt;

&lt;p&gt;Same task for every model: create a file and write a small program into it.&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;Result&lt;/th&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;claude-sonnet-4-6&lt;/td&gt;
&lt;td&gt;worked first try&lt;/td&gt;
&lt;td&gt;~7 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;deepseek-v3.2&lt;/td&gt;
&lt;td&gt;worked first try&lt;/td&gt;
&lt;td&gt;~9 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;qwen3.8-max&lt;/td&gt;
&lt;td&gt;worked first try&lt;/td&gt;
&lt;td&gt;~24 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;glm-5.3&lt;/td&gt;
&lt;td&gt;worked first try&lt;/td&gt;
&lt;td&gt;~45 s&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;kimi-k3&lt;/td&gt;
&lt;td&gt;failed once, worked on retry&lt;/td&gt;
&lt;td&gt;—&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two things worth knowing:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Prompt caching does a lot of work here.&lt;/strong&gt; Claude Code sends a long system prompt with every request. The first request wrote about 36K tokens to the cache; later ones read about 64K from it. Cache reads are billed well below normal input on most models, so long sessions cost less than the raw token count suggests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The &lt;code&gt;unrecognized_model&lt;/code&gt; line is expected.&lt;/strong&gt; Since 2.1.290, Claude Code auto-compacts sessions on model IDs it doesn't know (like &lt;code&gt;deepseek-v3.2&lt;/code&gt;) within an assumed context window and prints &lt;code&gt;[claude-code:unrecognized_model]&lt;/code&gt;. The task still runs. Set &lt;code&gt;CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENT=1&lt;/code&gt; if you want the old behavior.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt; vs &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt;.&lt;/strong&gt; The first is sent as &lt;code&gt;Authorization: Bearer&lt;/code&gt;, the second as &lt;code&gt;x-api-key&lt;/code&gt;. Use &lt;code&gt;AUTH_TOKEN&lt;/code&gt; to avoid the interactive confirmation prompt Claude Code shows the first time it sees an &lt;code&gt;API_KEY&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The full guide with the settings-file version and per-model notes is here: &lt;a href="https://xhuoapi.ai/en/guides/claude-code.html?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=claude-code" rel="noopener noreferrer"&gt;https://xhuoapi.ai/en/guides/claude-code.html?utm_source=devto&amp;amp;utm_medium=article&amp;amp;utm_campaign=claude-code&lt;/a&gt;&lt;/p&gt;

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