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
- Install Node.js.
- Create an API key in the ModelGo Console.
- Confirm a logical model name allowed for the API key in the Model Gallery.
1. Install Claude Code
Run:
npm install -g @anthropic-ai/claude-codeVerify the installation:
claude --version2. Configure ModelGo
macOS / Linux
Create and edit the Claude Code settings file:
mkdir -p ~/.claude
$EDITOR ~/.claude/settings.jsonWindows
Run these commands in PowerShell:
mkdir $env:USERPROFILE\.claude
notepad $env:USERPROFILE\.claude\settings.jsonPaste the following into settings.json. Replace YOUR_MODELGO_API_KEY and YOUR_MODELGO_MODEL with a real ModelGo API key and logical model name:
{
"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:
printf '%s\n' '{"hasCompletedOnboarding": true}' > ~/.claude.jsonWindows PowerShell:
'{"hasCompletedOnboarding": true}' | Set-Content -Encoding utf8 $env:USERPROFILE\.claude.json4. Start Claude Code
Change to your project directory and start Claude Code:
cd /path/to/your/project
claudeOn 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
| Setting | Value in ModelGo |
|---|---|
ANTHROPIC_AUTH_TOKEN | A ModelGo API key created in the Console |
ANTHROPIC_BASE_URL | https://api.modelgo.ai |
ANTHROPIC_MODEL | A ModelGo logical model name |
ANTHROPIC_SMALL_FAST_MODEL | The same callable ModelGo logical model name |
ANTHROPIC_DEFAULT_HAIKU_MODEL | The same callable ModelGo logical model name |
ANTHROPIC_DEFAULT_SONNET_MODEL | The same callable ModelGo logical model name |
ANTHROPIC_DEFAULT_OPUS_MODEL | The same callable ModelGo logical model name |
Find a model in the Model Gallery, or query the models available to the current API key:
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
- First call: create an API key, find a model, and verify a ModelGo request.
- Authentication: learn how to use and protect ModelGo API keys.
- Claude Code documentation: see the latest installation and configuration guidance.