Claude Code

Claude Code is a terminal-based AI coding assistant. Configure its Anthropic-compatible endpoint to use ModelGo models and API keys.

Before you start

1. Install Claude Code

Run:

bash
npm install -g @anthropic-ai/claude-code

Verify the installation:

bash
claude --version

2. Configure ModelGo

macOS / Linux

Create and edit the Claude Code settings file:

bash
mkdir -p ~/.claude
$EDITOR ~/.claude/settings.json

Windows

Run these commands in PowerShell:

powershell
mkdir $env:USERPROFILE\.claude
notepad $env:USERPROFILE\.claude\settings.json

Paste the following into settings.json. Replace YOUR_MODELGO_API_KEY and YOUR_MODELGO_MODEL with a real ModelGo API key and logical model name:

json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "YOUR_MODELGO_API_KEY",
    "ANTHROPIC_BASE_URL": "https://api.modelgo.ai",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "API_TIMEOUT_MS": "600000",
    "ANTHROPIC_MODEL": "YOUR_MODELGO_MODEL",
    "ANTHROPIC_SMALL_FAST_MODEL": "YOUR_MODELGO_MODEL",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "YOUR_MODELGO_MODEL",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "YOUR_MODELGO_MODEL",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "YOUR_MODELGO_MODEL"
  },
  "permissions": {
    "allow": [],
    "deny": []
  }
}

Use the ModelGo root URL for ANTHROPIC_BASE_URL; do not append /v1/messages. Claude Code adds the path and calls ModelGo's POST /v1/messages endpoint.

3. Optional: skip official account onboarding

If the first claude launch stops at the official account login flow, create .claude.json in your user directory with the completed-onboarding flag.

macOS / Linux:

bash
printf '%s\n' '{"hasCompletedOnboarding": true}' > ~/.claude.json

Windows PowerShell:

powershell
'{"hasCompletedOnboarding": true}' | Set-Content -Encoding utf8 $env:USERPROFILE\.claude.json

4. Start Claude Code

Change to your project directory and start Claude Code:

bash
cd /path/to/your/project
claude

On the first visit, choose Trust This Folder to allow Claude Code to access project files. Send a simple coding request; a normal response confirms the connection.

ModelGo values

SettingValue in ModelGo
ANTHROPIC_AUTH_TOKENA ModelGo API key created in the Console
ANTHROPIC_BASE_URLhttps://api.modelgo.ai
ANTHROPIC_MODELA ModelGo logical model name
ANTHROPIC_SMALL_FAST_MODELThe same callable ModelGo logical model name
ANTHROPIC_DEFAULT_HAIKU_MODELThe same callable ModelGo logical model name
ANTHROPIC_DEFAULT_SONNET_MODELThe same callable ModelGo logical model name
ANTHROPIC_DEFAULT_OPUS_MODELThe same callable ModelGo logical model name

Find a model in the Model Gallery, or query the models available to the current API key:

bash
curl https://api.modelgo.ai/v1/models \
  -H "Authorization: Bearer $MODELGO_API_KEY"

Troubleshooting

401 or authentication failed

Check that ANTHROPIC_AUTH_TOKEN is a valid ModelGo API key and contains no extra spaces.

403 or model unavailable

Make sure all five model variables use ModelGo logical model names allowed by the policy attached to the API key.

404 or endpoint not found

Set ANTHROPIC_BASE_URL to https://api.modelgo.ai, not https://api.modelgo.ai/v1/messages; Claude Code adds /v1/messages itself.

Related docs