B2BB2B LLM

Claude Code

Install and permanently configure Claude Code to use the Anthropic-compatible Model Gate endpoint.

Claude Code through Model Gate

This guide uses a permanent settings.json configuration. ANTHROPIC_BASE_URL must be specified without /v1.

Required values

ANTHROPIC_BASE_URL=https://api.model-gate.com
ANTHROPIC_AUTH_TOKEN=mg_live_...

ANTHROPIC_AUTH_TOKEN is sent as a Bearer token. Model Gate also accepts x-api-key, but the auth-token form is appropriate for an LLM gateway.

1. Install Claude Code

macOS or Linux native installer

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

npm alternative

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

Windows PowerShell

irm https://claude.ai/install.ps1 | iex

Close and reopen the terminal, then verify:

claude --version

Use the current official installation instructions when the installer changes: https://docs.anthropic.com/en/docs/claude-code/getting-started.

2. Create the settings directory

Linux or macOS

mkdir -p ~/.claude
nano ~/.claude/settings.json

Windows PowerShell

New-Item -ItemType Directory -Force "$HOME\.claude" | Out-Null
notepad "$HOME\.claude\settings.json"
{
  "$schema": "https://json.schemastore.org/claude-code-settings.json",
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.model-gate.com",
    "ANTHROPIC_AUTH_TOKEN": "mg_live_...",
    "ANTHROPIC_MODEL": "claude-sonnet-4.6",
    "ANTHROPIC_SMALL_FAST_MODEL": "claude-haiku-4.5"
  },
  "model": "claude-sonnet-4.6"
}

Replace the model IDs with enabled IDs returned by:

curl https://api.model-gate.com/v1/models \
  -H "Authorization: Bearer mg_live_..."

4. Override the Opus, Sonnet, and Haiku slots

Claude Code exposes three standard model slots. You can map them to Model Gate model IDs:

{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.model-gate.com",
    "ANTHROPIC_AUTH_TOKEN": "mg_live_...",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4.7",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4.6",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "claude-haiku-4.5"
  }
}

These values override the three standard slots; they do not create unlimited new GUI buttons.

5. Optional privacy and timeout settings

Add only settings you understand:

{
  "env": {
    "DISABLE_TELEMETRY": "1",
    "DISABLE_ERROR_REPORTING": "1",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": "1",
    "BASH_DEFAULT_TIMEOUT_MS": "120000",
    "BASH_MAX_TIMEOUT_MS": "600000"
  }
}

Do not enable permission bypass globally unless you understand the security impact. Model Gate does not require bypassPermissions.

6. Start Claude Code

claude

Use /model to inspect or change the selected model.

7. One-time test without settings.json

Linux or macOS

export ANTHROPIC_BASE_URL="https://api.model-gate.com"
export ANTHROPIC_AUTH_TOKEN="mg_live_..."
claude

Windows PowerShell

$env:ANTHROPIC_BASE_URL = "https://api.model-gate.com"
$env:ANTHROPIC_AUTH_TOKEN = "mg_live_..."
claude

Troubleshooting

ProblemResolution
claude is not foundClose and reopen the terminal, then run claude --version. Check where.exe claude on Windows or which claude on Unix.
Authentication is requestedVerify ANTHROPIC_AUTH_TOKEN, close Claude Code, and start it again.
Model is not foundUse a canonical ID or enabled alias returned by /v1/models.
Requests go to Anthropic directlyConfirm the base URL is exactly https://api.model-gate.com without /v1.
401 invalid_api_keyRotate the Model Gate key and update settings.json.

Official gateway reference: https://docs.anthropic.com/en/docs/claude-code/llm-gateway.