Claude Code Setup
If you already have Claude Code (Anthropic's terminal / IDE coding assistant) installed, follow these steps to connect Gate.AI.
1. Create a Gate.AI API key
- Go to Dashboard → Settings → API Keys and create a key.
- Copy the key that starts with sk-v1- and use it to replace the placeholders below.
- For auto routing : go to Dashboard → Settings → Routing and enable Auto routing . When it is off, specify a model ID explicitly in each request.
2. Configure Anthropic Base URL and API key
Claude Code reads environment variables. We recommend following the official LLM gateway documentation and setting:
| Variable | Value |
|---|---|
ANTHROPIC_BASE_URL | https://api.gate.ai/anthropic |
ANTHROPIC_API_KEY | Your Gate.AI API key (sk-v1-…) |
Option A: Current terminal session (temporary)
1export ANTHROPIC_BASE_URL="https://api.gate.ai/anthropic"2export ANTHROPIC_API_KEY="sk-v1-xxxxxxxxxxxxxxxx"3claudeOption B: Shell profile
Append the following to ~/.zshrc or ~/.bashrc:
1export ANTHROPIC_BASE_URL="https://api.gate.ai/anthropic"2export ANTHROPIC_API_KEY="sk-v1-xxxxxxxxxxxxxxxx"After running source ~/.zshrc (or opening a new terminal), run claude.
Option C: Claude Code settings.json (recommended)
In user-level or project-level configuration, add an env block (see Claude Code settings for paths), for example in your project directory .claude/settings.json:
1{2 "env": {3 "ANTHROPIC_BASE_URL": "https://api.gate.ai/anthropic",4 "ANTHROPIC_API_KEY": "sk-v1-xxxxxxxxxxxxxxxx"5 }6}Security note: Do not commit real keys to a public repository; use your OS secret store or CI secret injection, and keep local secrets in environment variables only.
Bypass the gateway and use Anthropic directly
To temporarily skip the gateway:
1env -u ANTHROPIC_BASE_URL -u ANTHROPIC_API_KEY claude(You must already have Anthropic official credentials or another default provider configured.)
3. Configure models (Gate.AI model IDs)
In Gate.AI docs, model IDs look like provider/model-name (for example anthropic/claude-sonnet-4.6). They are not identical to Claude Code built-in aliases such as sonnet. Pick one approach:
3.1 Default model via environment variable
1export ANTHROPIC_MODEL="anthropic/claude-sonnet-4.6"Or add the same key under env in settings.json.
3.2 Alias mapping
Map aliases to Gate.AI model IDs (Sonnet example):
1export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4.6"2export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic/claude-opus-4.6"3export ANTHROPIC_DEFAULT_HAIKU_MODEL="anthropic/claude-haiku-4.5"Use the Gate.AI docs — Models list as the source of truth for IDs.
3.3 Custom entry in /model
To pick a gateway-backed model in the UI, use Claude Code's custom model option (see the official Model configuration - ANTHROPIC_CUSTOM_MODEL_OPTION):
1export ANTHROPIC_CUSTOM_MODEL_OPTION="anthropic/claude-sonnet-4.6"2export ANTHROPIC_CUSTOM_MODEL_OPTION_NAME="Sonnet (Gate.AI)"3.4 Auto-routing model auto
If auto routing is enabled in the dashboard, you can try setting ANTHROPIC_MODEL to auto (same meaning as auto on the OpenAI setup page). If you see errors, switch back to an explicit model ID such as anthropic/claude-sonnet-4.6.
4. Verify the setup
- In a terminal with the environment configured, run:
1claude- After the session starts, send a simple prompt, for example: In one sentence, introduce yourself.
- If you get a normal reply with no auth or routing errors, requests are reaching Gate.AI and the selected model is responding.
5. FAQ
| Symptom | Likely cause | What to try |
|---|---|---|
| 401 / auth failure | Wrong API key or env not exported | Check ANTHROPIC_API_KEY matches the dashboard key |
| 404 on URL | Base URL points at the OpenAI path | Use https://api.gate.ai/anthropic |
| Model missing / routing error | Bad model ID or model not allowed | Compare with the Models table; check routing and allow lists in the dashboard |
| Still hitting Anthropic directly | Env vars not applied | Confirm settings.json scope; in a new shell run echo $ANTHROPIC_BASE_URL to verify |