Modelflare Blog

Claude Code on Modelflare in depth: installer, settings.json, model slots, and troubleshooting

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.

Illustration: a stack of request cards routed through one panel to several modules

Modelflare serves Claude Code over the Anthropic Messages family. An earlier article gave Claude Code a short summary next to five other clients, and the Codex guide went through Codex in the same format as this one. Here we follow the Claude Code setup guide step by step. Every command and file below is copied from that page.

Start with the key

Both setup paths need a Modelflare API key whose non-default group can access claude-opus-4-8 and claude-sonnet-5. Create it under API Keys in the console. The models and groups guide 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.

Option A: the installer

On macOS or Linux, run the installer as your normal user:

curl -fsSL https://modelflare.dev/install/claude.sh | sh

On Windows, open PowerShell as your normal Windows user and run:

irm https://modelflare.dev/install/claude.ps1 | iex

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.

The interactive first-run guide is a simulated Mac or Windows walkthrough of the same prompts; it does not change your computer. The language prompt reads Choose 1, 2, or 3 [3]:, and English is option 3. Next, the official installer runs (Installing Claude Code with the official installer...). Then the script asks for the key, and the input stays visible while you paste it. If validation passes, the script prints API key validation passed: claude-opus-4-8 and claude-sonnet-5 are available. and then Setup complete. Claude Code is configured for Modelflare and was not started.

Root on a VPS or in a container

If you are already logged in as root on a VPS or in a container, set MODELFLARE_ALLOW_ROOT=1 for the shell that runs the script:

curl -fsSL https://modelflare.dev/install/claude.sh | MODELFLARE_ALLOW_ROOT=1 sh

The docs say not to add sudo on a personal computer. On a workstation, run the plain command as yourself so the settings go into your own ~/.claude.

Option B: writing settings.json yourself

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:

curl -fsSL https://claude.ai/install.sh | bash
claude --version

Create the user settings directory and enter it:

mkdir -p ~/.claude
cd ~/.claude

Replace YOUR_MODELFLARE_API_KEY with your complete key, then write the file:

cat > settings.json << 'EOF'
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://modelflare.dev",
    "ANTHROPIC_AUTH_TOKEN": "YOUR_MODELFLARE_API_KEY",
    "ANTHROPIC_MODEL": "claude-opus-4-8",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-8",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-5",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-sonnet-5"
  }
}
EOF
chmod 600 settings.json

The chmod 600 limits the file to your user, which matches the authentication rules: credentials files should stay user-private. The PowerShell variant of this step writes the same JSON as UTF-8 without a byte-order mark.

The env block, line by line

Two variables set up the connection:

The other four variables fill the model slots:

All values must be exact catalog IDs. The models guide warns against swapping in a marketing name, a date suffix, or a nearby variant.

Verify the connection

With Option B, the fourth step starts Claude Code in a fresh project folder:

cd ~
mkdir -p my-claude-project
cd my-claude-project
claude

After Option A, enter a project directory you trust and start it yourself:

claude

With either method, send:

Reply with one sentence confirming the active model.

If you get a normal reply, setup is complete.

Troubleshooting

The Claude Code page has no troubleshooting table. The general errors guide and the authentication guide cover the cases you are likely to hit:

Status Documented cause Where to look
401 The key is missing, malformed, or revoked. The ANTHROPIC_AUTH_TOKEN value
403 The key is valid, but it cannot use this model or group. The key's group must list both Claude models
429 Rate limit. Request volume
5xx Service provider or gateway failure. Retry, or use group fallback

Failed requests return JSON with an error object. Its message and 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 claude-sonnet-5 even when you are working in Opus.

To switch between Claude Code profiles, the CC-Switch guide covers the Import to CC Switch action on the API Keys page. Choose Claude Code, 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 business@modelflare.dev.

← All articles