<?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: he hongsheng</title>
    <description>The latest articles on DEV Community by he hongsheng (@he_hongsheng_d512008e9af3).</description>
    <link>https://dev.to/he_hongsheng_d512008e9af3</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%2F4190247%2F4088d7ae-085e-4ea5-9e58-329c7e8f7842.png</url>
      <title>DEV Community: he hongsheng</title>
      <link>https://dev.to/he_hongsheng_d512008e9af3</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/he_hongsheng_d512008e9af3"/>
    <language>en</language>
    <item>
      <title>Claude Code API Gateways on Windows: Verify Base URL and Authentication Before Debugging Models</title>
      <dc:creator>he hongsheng</dc:creator>
      <pubDate>Sat, 17 Oct 2026 10:13:35 +0000</pubDate>
      <link>https://dev.to/he_hongsheng_d512008e9af3/claude-code-api-gateways-on-windows-verify-base-url-and-authentication-before-debugging-models-4d18</link>
      <guid>https://dev.to/he_hongsheng_d512008e9af3/claude-code-api-gateways-on-windows-verify-base-url-and-authentication-before-debugging-models-4d18</guid>
      <description>&lt;p&gt;Many Claude Code gateway failures are diagnosed too late. People often change the model name first, even though the request is still going to the wrong host or using the wrong authentication header.&lt;/p&gt;

&lt;p&gt;This guide uses a narrow workflow for Windows: verify the gateway protocol, select the matching credential variable, test the connection in one PowerShell session, and only then make the configuration persistent. It does not assume that an OpenAI-compatible endpoint can serve Claude Code.&lt;/p&gt;

&lt;h2&gt;
  
  
  The three values that must agree
&lt;/h2&gt;

&lt;p&gt;A working setup has three independent pieces:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Base URL&lt;/strong&gt;: the URL supplied by the service for Claude Code or an Anthropic-compatible gateway. Do not derive it from a dashboard login URL.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Credential type&lt;/strong&gt;: a Bearer token normally maps to &lt;code&gt;ANTHROPIC_AUTH_TOKEN&lt;/code&gt;; an &lt;code&gt;x-api-key&lt;/code&gt; flow maps to &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt;. The service documentation decides which one is correct.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Protocol and path&lt;/strong&gt;: Claude Code needs the gateway to support the Anthropic Messages format, commonly exposed under &lt;code&gt;/v1/messages&lt;/code&gt;. A service that only documents OpenAI Responses or Chat Completions is a different integration.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If any one of these values is guessed, a later model error is not useful evidence.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test from one PowerShell session
&lt;/h2&gt;

&lt;p&gt;Start with temporary variables so that a failed experiment is easy to remove:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$&lt;/span&gt;&lt;span class="nn"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_BASE_URL&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"https://gateway.example.com"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="nv"&gt;$&lt;/span&gt;&lt;span class="nn"&gt;env&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="nv"&gt;ANTHROPIC_AUTH_TOKEN&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="n"&gt;Read-Host&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Enter the gateway token"&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nt"&gt;-MaskInput&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="n"&gt;claude&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the example host and token flow with the values from the current service documentation. If the service specifies an API key header instead, use &lt;code&gt;ANTHROPIC_API_KEY&lt;/code&gt; and do not set both variables at the same time.&lt;/p&gt;

&lt;p&gt;Launching &lt;code&gt;claude&lt;/code&gt; from the same PowerShell window matters. Setting a variable in one shell and starting the CLI from another can make a correct value appear to be missing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Verify the route before changing models
&lt;/h2&gt;

&lt;p&gt;Inside the Claude Code session:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Send a small, non-sensitive test message.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;/status&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Check that the displayed base URL and credential source match the values you intended to use.&lt;/li&gt;
&lt;li&gt;Only after that, investigate model availability or request limits.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A visible environment variable is not proof that the gateway accepted the request. The test message and status output provide two separate checks: process inheritance and an actual request path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Read the error as a branch, not a verdict
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;401 Unauthorized&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Check the credential type first. A Bearer token sent through the &lt;code&gt;x-api-key&lt;/code&gt; variable, or an API key sent through the Authorization flow, can fail even when the string itself is valid. Also check that the token belongs to the current gateway.&lt;/p&gt;

&lt;h3&gt;
  
  
  Claude Code still asks for login
&lt;/h3&gt;

&lt;p&gt;The CLI may not have inherited the variables, or a higher-priority settings file may be taking precedence. Confirm the launch directory and inspect the active settings source before changing credentials.&lt;/p&gt;

&lt;h3&gt;
  
  
  The address is reachable but the response format is invalid
&lt;/h3&gt;

&lt;p&gt;Network reachability only proves that something answered. Re-check whether the endpoint implements the Anthropic Messages format and whether the path is the one documented for Claude Code. Do not copy a Codex or OpenAI configuration into this workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  Persist only after the temporary test works
&lt;/h2&gt;

&lt;p&gt;When the temporary session works, a user-level settings file can hold the environment block. Keep real credentials out of project files, screenshots, public issues, and repositories. A shared &lt;code&gt;.claude/settings.json&lt;/code&gt; is especially easy to commit by accident.&lt;/p&gt;

&lt;p&gt;For a longer Windows walkthrough with the exact variable choices, &lt;code&gt;/status&lt;/code&gt; checks, and cleanup steps, see the &lt;a href="https://ai.xiao-he.top/claude-code-api-config.html" rel="noopener noreferrer"&gt;Claude Code API configuration guide&lt;/a&gt;. It also explains when a service should be rejected because it documents only an incompatible protocol.&lt;/p&gt;

&lt;h2&gt;
  
  
  Official references
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://code.claude.com/docs/en/llm-gateway-connect" rel="noopener noreferrer"&gt;Connect Claude Code to an LLM gateway&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://code.claude.com/docs/en/env-vars" rel="noopener noreferrer"&gt;Claude Code environment variables&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://code.claude.com/docs/en/settings" rel="noopener noreferrer"&gt;Claude Code settings&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The workflow above is intentionally conservative: a successful configuration means that the selected client, protocol, address, and credential source agree. It does not claim that every gateway supports Claude Code, nor that a single successful request proves production reliability.&lt;/p&gt;

</description>
      <category>debugging</category>
      <category>claudecode</category>
      <category>api</category>
    </item>
  </channel>
</rss>
