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

    1. Go to Dashboard → Settings → API Keys and create a key.
    2. Copy the key that starts with sk-v1- and use it to replace the placeholders below.
    3. 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:

    VariableValue
    ANTHROPIC_BASE_URLhttps://api.gate.ai/anthropic
    ANTHROPIC_API_KEYYour Gate.AI API key (sk-v1-…)

    Option A: Current terminal session (temporary)

    bash
    1export ANTHROPIC_BASE_URL="https://api.gate.ai/anthropic"2export ANTHROPIC_API_KEY="sk-v1-xxxxxxxxxxxxxxxx"3claude

    Option B: Shell profile

    Append the following to ~/.zshrc or ~/.bashrc:

    bash
    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.

    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:

    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:

    bash
    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

    bash
    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):

    bash
    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):

    bash
    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

    1. In a terminal with the environment configured, run:
    bash
    1claude
    1. After the session starts, send a simple prompt, for example: In one sentence, introduce yourself.
    2. 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

    SymptomLikely causeWhat to try
    401 / auth failureWrong API key or env not exportedCheck ANTHROPIC_API_KEY matches the dashboard key
    404 on URLBase URL points at the OpenAI pathUse https://api.gate.ai/anthropic
    Model missing / routing errorBad model ID or model not allowedCompare with the Models table; check routing and allow lists in the dashboard
    Still hitting Anthropic directlyEnv vars not appliedConfirm settings.json scope; in a new shell run echo $ANTHROPIC_BASE_URL to verify