Connect Claude Code to ModelGo: Setup & Troubleshooting

Claude Code is a terminal-based AI coding assistant. It connects to ModelGo through the Anthropic-compatible API. Before you start, create an API key in the ModelGo console and pick a logical model name your key can call from the Model Catalog.

1. Install

Use the official native installer (macOS / Linux / WSL; on Windows PowerShell run irm https://claude.ai/install.ps1 | iex):

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

You can also install it with npm install -g @anthropic-ai/claude-code (requires Node.js 22 or later).

2. Configure ModelGo

Edit ~/.claude/settings.json (Windows: %USERPROFILE%\.claude\settings.json):

json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "mgk_your_api_key",
    "ANTHROPIC_BASE_URL": "https://api.modelgo.ai",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "API_TIMEOUT_MS": "600000",
    "ANTHROPIC_MODEL": "your-model-id",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "your-model-id",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "your-model-id",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "your-model-id"
  }
}

If the first run stops at the official account onboarding, skip it with printf '%s\n' '{"hasCompletedOnboarding": true}' > ~/.claude.json.

3. Start and verify

Run claude in a project directory, choose Trust This Folder, and send a simple request. A normal reply means the setup works. To check the key and the models it can call:

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

Troubleshooting

  • 401: check that ANTHROPIC_AUTH_TOKEN is a valid ModelGo API key with no extra spaces.
  • 403 / model unavailable: all four model variables must be logical model names your API key can call.
  • 404: ANTHROPIC_BASE_URL must be https://api.modelgo.ai, not https://api.modelgo.ai/v1/messages.

Tool search returns HTTP 400

If error.metadata.upstream_reason is tool_reference_unsupported or deferred_tools_unsupported, the current route rejected on-demand tool loading. Add "ENABLE_TOOL_SEARCH": "false" to env in your existing settings.json, then exit and start a new claude session. Claude Code loads MCP tool definitions up front. Claude Code tool search settings

For GPT-6 Astra routing and the API message format, see Custom tool search in Anthropic Messages.

Related docs