File size: 16,037 Bytes
814a384
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Claude Code on Modelflare in depth: installer, settings.json, model slots, and troubleshooting | Modelflare Blog</title>
<meta name="description" content="Claude Code reaches Modelflare through Anthropic Messages, with ANTHROPIC_BASE_URL set to the site origin https://modelflare.dev rather than /v1. All of the configuration sits in the env block of one user file, ~/.claude/settings.json. This guide covers the installer and its root variant, the manual setup, each variable in that block, and how to read the errors documented for keys and groups."><meta property="og:image" content="https://modelflare-blog.static.hf.space/images/claude-code-in-depth-cover.jpg"><meta property="og:image:width" content="1200"><meta property="og:image:height" content="630"><meta property="og:title" content="Claude Code on Modelflare in depth: installer, settings.json, model slots, and troubleshooting"><meta property="og:description" content="Claude Code reaches Modelflare through Anthropic Messages, with ANTHROPIC_BASE_URL set to the site origin https://modelflare.dev rather than /v1. All of the configuration sits in the env block of one user file, ~/.claude/settings.json. This guide covers the installer and its root variant, the manual setup, each variable in that block, and how to read the errors documented for keys and groups."><meta property="og:type" content="article"><meta property="og:url" content="https://modelflare-blog.static.hf.space/claude-code-in-depth.html"><meta property="og:site_name" content="Modelflare Blog"><meta property="article:published_time" content="2026-10-27"><link rel="canonical" href="https://modelflare-blog.static.hf.space/claude-code-in-depth.html"><meta name="twitter:card" content="summary_large_image"><meta name="twitter:title" content="Claude Code on Modelflare in depth: installer, settings.json, model slots, and troubleshooting"><meta name="twitter:description" content="Claude Code reaches Modelflare through Anthropic Messages, with ANTHROPIC_BASE_URL set to the site origin https://modelflare.dev rather than /v1. All of the configuration sits in the env block of one user file, ~/.claude/settings.json. This guide covers the installer and its root variant, the manual setup, each variable in that block, and how to read the errors documented for keys and groups."><meta name="twitter:image" content="https://modelflare-blog.static.hf.space/images/claude-code-in-depth-cover.jpg">
<style>
:root{--bg:#0b1020;--card:#121a2f;--text:#e8ecf7;--muted:#9aa6c2;--accent:#8b5cf6;--accent2:#ec4899;--border:rgba(255,255,255,.08)}
*{box-sizing:border-box}
body{margin:0;font-family:ui-sans-serif,system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;background:radial-gradient(1200px 600px at 10% -10%,#2a1850 0%,transparent 50%),radial-gradient(900px 500px at 100% 0%,#3b0f2e 0%,transparent 45%),var(--bg);color:var(--text);min-height:100vh;line-height:1.65}
.wrap{max-width:860px;margin:0 auto;padding:28px 18px 64px}
header.top{display:flex;flex-wrap:wrap;gap:14px;align-items:center;justify-content:space-between;margin-bottom:28px;font-size:14px}
header.top a{color:var(--muted);text-decoration:none}header.top a:hover{color:#fff}
header.top .brand{color:#fff;font-weight:700;font-size:16px}
header.top nav{display:flex;flex-wrap:wrap;gap:14px}
h1{font-size:clamp(26px,4.6vw,38px);line-height:1.2;margin:0 0 12px}
h2{font-size:22px;margin:36px 0 10px}h3{font-size:17px;margin:24px 0 8px;color:#d6c7ff}
p,li{color:#cfd6e8}a{color:#c4b5fd}
.lead{color:var(--muted);font-size:17px}
article img{max-width:100%;height:auto;border-radius:12px;border:1px solid var(--border);display:block;margin:18px auto 6px}
article p em:only-child{display:block;text-align:center;color:var(--muted);font-size:14px}
pre{background:#070b16;border:1px solid var(--border);border-radius:12px;padding:0;overflow-x:auto}
pre code.hljs{background:transparent;padding:14px 16px;font-size:13.5px;line-height:1.55}
code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:.92em}
p code,li code,td code{background:rgba(139,92,246,.14);padding:1px 5px;border-radius:5px}
table{border-collapse:collapse;width:100%;font-size:14px;margin:14px 0;display:block;overflow-x:auto}
th,td{border:1px solid var(--border);padding:8px 10px;text-align:left;vertical-align:top}th{background:var(--card)}
hr{border:0;border-top:1px solid var(--border);margin:32px 0}
.list{display:grid;gap:14px}
.card{display:flex;gap:16px;background:var(--card);border:1px solid var(--border);border-radius:16px;padding:18px;text-decoration:none;color:inherit}
.card:hover{border-color:rgba(139,92,246,.5)}
.card img{width:200px;height:105px;object-fit:cover;border-radius:10px;flex-shrink:0}
.card h2{font-size:18px;margin:0 0 6px;color:#fff}.card p{margin:0;color:var(--muted);font-size:14px}
footer{margin-top:48px;padding-top:18px;border-top:1px solid var(--border);color:var(--muted);font-size:13px}
footer a{color:var(--muted)}
@media(max-width:600px){.card{flex-direction:column}.card img{width:100%;height:auto;aspect-ratio:1200/630}}
</style>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.9.0/styles/github-dark.min.css"><script src="https://cdn.jsdelivr.net/npm/@highlightjs/cdn-assets@11.9.0/highlight.min.js"></script><script>document.addEventListener("DOMContentLoaded",()=>hljs.highlightAll());</script>
</head>
<body><div class="wrap"><header class="top"><a class="brand" href="index.html">Modelflare Blog</a><nav><a href="https://modelflare.dev/?utm_source=huggingface&utm_medium=space&utm_campaign=blog">modelflare.dev</a><a href="https://docs.modelflare.dev/?utm_source=huggingface&utm_medium=space&utm_campaign=blog">Docs</a><a href="https://castaly.modelflare.dev/?utm_source=huggingface&utm_medium=space&utm_campaign=blog">Castaly</a><a href="https://huggingface.co/Modelflare" target="_top">Hugging Face org</a></nav></header>
<article><h1>Claude Code on Modelflare in depth: installer, settings.json, model slots, and troubleshooting</h1>
<p class="lead">Claude Code reaches Modelflare through Anthropic Messages, with <code>ANTHROPIC_BASE_URL</code> set to the site origin <code>https://modelflare.dev</code> rather than <code>/v1</code>. All of the configuration sits in the <code>env</code> block of one user file, <code>~/.claude/settings.json</code>. This guide covers the installer and its root variant, the manual setup, each variable in that block, and how to read the errors documented for keys and groups.</p>
<img src="images/claude-code-in-depth-cover.jpg" alt="Illustration: a stack of request cards routed through one panel to several modules">
<hr />
<p><a href="https://modelflare.dev/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">Modelflare</a> serves Claude Code over the Anthropic Messages family. An <a href="coding-agents-modelflare.html">earlier article</a> gave Claude Code a short summary next to five other clients, and <a href="codex-cli-in-depth.html">the Codex guide</a> went through Codex in the same format as this one. Here we follow the <a href="https://docs.modelflare.dev/guides/clients/claude-code/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">Claude Code setup guide</a> step by step. Every command and file below is copied from that page.</p>
<h2>Start with the key</h2>
<p>Both setup paths need a Modelflare API key whose non-default group can access <code>claude-opus-4-8</code> and <code>claude-sonnet-5</code>. Create it under <strong>API Keys</strong> in the console. The <a href="https://docs.modelflare.dev/guides/models-and-groups/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">models and groups guide</a> says that no single group is required. The key's group only has to list both models. The installer asks for the complete key once.</p>
<h2>Option A: the installer</h2>
<p>On macOS or Linux, run the installer as your normal user:</p>
<pre><code class="language-bash">curl -fsSL https://modelflare.dev/install/claude.sh | sh
</code></pre>
<p>On Windows, open PowerShell as your normal Windows user and run:</p>
<pre><code class="language-powershell">irm https://modelflare.dev/install/claude.ps1 | iex
</code></pre>
<p>The script asks for a language (Simplified Chinese, Japanese, or English). It installs the official Claude Code CLI when needed and asks for the Modelflare API key once. Then it backs up your existing user settings, merges the new values into them, and checks both configured models. It does not start Claude Code.</p>
<p>The <a href="https://docs.modelflare.dev/guides/clients/claude-code/start/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">interactive first-run guide</a> is a simulated Mac or Windows walkthrough of the same prompts; it does not change your computer. The language prompt reads <code>Choose 1, 2, or 3 [3]:</code>, and English is option 3. Next, the official installer runs (<code>Installing Claude Code with the official installer...</code>). Then the script asks for the key, and the input stays visible while you paste it. If validation passes, the script prints <code>API key validation passed: claude-opus-4-8 and claude-sonnet-5 are available.</code> and then <code>Setup complete. Claude Code is configured for Modelflare and was not started.</code></p>
<h3>Root on a VPS or in a container</h3>
<p>If you are already logged in as <code>root</code> on a VPS or in a container, set <code>MODELFLARE_ALLOW_ROOT=1</code> for the shell that runs the script:</p>
<pre><code class="language-bash">curl -fsSL https://modelflare.dev/install/claude.sh | MODELFLARE_ALLOW_ROOT=1 sh
</code></pre>
<p>The docs say not to add <code>sudo</code> on a personal computer. On a workstation, run the plain command as yourself so the settings go into your own <code>~/.claude</code>.</p>
<h2>Option B: writing settings.json yourself</h2>
<p>The manual path has four steps, each with PowerShell, Linux, and macOS variants; the Linux and macOS commands are identical. First install Claude Code with the upstream installer and confirm the version:</p>
<pre><code class="language-bash">curl -fsSL https://claude.ai/install.sh | bash
claude --version
</code></pre>
<p>Create the user settings directory and enter it:</p>
<pre><code class="language-bash">mkdir -p ~/.claude
cd ~/.claude
</code></pre>
<p>Replace <code>YOUR_MODELFLARE_API_KEY</code> with your complete key, then write the file:</p>
<pre><code class="language-bash">cat &gt; settings.json &lt;&lt; 'EOF'
{
  &quot;env&quot;: {
    &quot;ANTHROPIC_BASE_URL&quot;: &quot;https://modelflare.dev&quot;,
    &quot;ANTHROPIC_AUTH_TOKEN&quot;: &quot;YOUR_MODELFLARE_API_KEY&quot;,
    &quot;ANTHROPIC_MODEL&quot;: &quot;claude-opus-4-8&quot;,
    &quot;ANTHROPIC_DEFAULT_OPUS_MODEL&quot;: &quot;claude-opus-4-8&quot;,
    &quot;ANTHROPIC_DEFAULT_SONNET_MODEL&quot;: &quot;claude-sonnet-5&quot;,
    &quot;ANTHROPIC_DEFAULT_HAIKU_MODEL&quot;: &quot;claude-sonnet-5&quot;
  }
}
EOF
chmod 600 settings.json
</code></pre>
<p>The <code>chmod 600</code> limits the file to your user, which matches the <a href="https://docs.modelflare.dev/guides/authentication/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">authentication rules</a>: credentials files should stay user-private. The PowerShell variant of this step writes the same JSON as UTF-8 without a byte-order mark.</p>
<h2>The env block, line by line</h2>
<p>Two variables set up the connection:</p>
<ul>
<li><code>ANTHROPIC_BASE_URL</code> is <code>https://modelflare.dev</code>, the site origin. The <a href="https://docs.modelflare.dev/guides/endpoints/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">endpoints guide</a> calls Anthropic clients the exception to the <code>/v1</code> base URL, because the Claude Code CLI appends the Messages path itself.</li>
<li><code>ANTHROPIC_AUTH_TOKEN</code> holds the Modelflare API key.</li>
</ul>
<p>The other four variables fill the model slots:</p>
<ul>
<li><code>ANTHROPIC_MODEL</code> is the default model, <code>claude-opus-4-8</code>.</li>
<li><code>ANTHROPIC_DEFAULT_OPUS_MODEL</code> maps the Opus alias to <code>claude-opus-4-8</code>.</li>
<li><code>ANTHROPIC_DEFAULT_SONNET_MODEL</code> maps the Sonnet alias to <code>claude-sonnet-5</code>.</li>
<li><code>ANTHROPIC_DEFAULT_HAIKU_MODEL</code> maps the Haiku alias to <code>claude-sonnet-5</code> as well. The guide describes this as an explicit model alias for background tasks. Every slot therefore resolves to one of the two models the key was created for.</li>
</ul>
<p>All values must be exact catalog IDs. The models guide warns against swapping in a marketing name, a date suffix, or a nearby variant.</p>
<h2>Verify the connection</h2>
<p>With Option B, the fourth step starts Claude Code in a fresh project folder:</p>
<pre><code class="language-bash">cd ~
mkdir -p my-claude-project
cd my-claude-project
claude
</code></pre>
<p>After Option A, enter a project directory you trust and start it yourself:</p>
<pre><code class="language-bash">claude
</code></pre>
<p>With either method, send:</p>
<pre><code class="language-text">Reply with one sentence confirming the active model.
</code></pre>
<p>If you get a normal reply, setup is complete.</p>
<h2>Troubleshooting</h2>
<p>The Claude Code page has no troubleshooting table. The general <a href="https://docs.modelflare.dev/guides/errors/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">errors guide</a> and the authentication guide cover the cases you are likely to hit:</p>
<table>
<thead>
<tr>
<th>Status</th>
<th>Documented cause</th>
<th>Where to look</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>401</code></td>
<td>The key is missing, malformed, or revoked.</td>
<td>The <code>ANTHROPIC_AUTH_TOKEN</code> value</td>
</tr>
<tr>
<td><code>403</code></td>
<td>The key is valid, but it cannot use this model or group.</td>
<td>The key's group must list both Claude models</td>
</tr>
<tr>
<td><code>429</code></td>
<td>Rate limit.</td>
<td>Request volume</td>
</tr>
<tr>
<td><code>5xx</code></td>
<td>Service provider or gateway failure.</td>
<td>Retry, or use group fallback</td>
</tr>
</tbody>
</table>
<p>Failed requests return JSON with an <code>error</code> object. Its <code>message</code> and <code>code</code> fields name the actual failure. A valid request can still fail when the key's group has no channel for the requested model. This matters for the Haiku slot, which sends <code>claude-sonnet-5</code> even when you are working in Opus.</p>
<p>To switch between Claude Code profiles, the <a href="https://docs.modelflare.dev/guides/clients/cc-switch/?utm_source=huggingface&amp;utm_medium=space&amp;utm_campaign=claude-code-in-depth">CC-Switch guide</a> covers the <strong>Import to CC Switch</strong> action on the API Keys page. Choose <strong>Claude Code</strong>, confirm the primary model, and then enable the imported provider in CC-Switch. Importing does not switch the active provider by itself. For team setups or volume usage, contact <a href="mailto:business@modelflare.dev">business@modelflare.dev</a>.</p></article><p><a href="index.html">&larr; All articles</a></p>
<footer>Modelflare on Hugging Face: <a href="https://huggingface.co/spaces/Modelflare/start" target="_top">start</a> 路 <a href="https://huggingface.co/spaces/Modelflare/openai-sdk" target="_top">openai-sdk</a> 路 <a href="https://huggingface.co/spaces/Modelflare/coding-agents" target="_top">coding-agents</a> 路 <a href="https://huggingface.co/spaces/Modelflare/api-recipes" target="_top">api-recipes</a> 路 <a href="https://huggingface.co/datasets/Modelflare/api-examples" target="_top">api-examples dataset</a><br>Business: <a href="mailto:business@modelflare.dev">business@modelflare.dev</a></footer></div></body>
</html>