Gate.AI Documentation

    A unified AI model routing platform. One API key, … models, smart auto-routing.


    Getting Started

    1. Create an API key

    1. Go to gate.ai, choose login method, and authorize
    2. Go to Console → Settings → API keys → Create a key

    2. Auto routing (optional)

    Auto routing is enabled by default. To control it:

    Console → Settings → Routing → Auto routing toggle

    Once enabled, Gate.AI automatically selects the best model for each request. If you prefer to pick models yourself, skip this step and specify models directly (e.g. anthropic/claude-sonnet-4.6).


    Standard Setup

    Fully compatible with the OpenAI API. Supports Python, Node.js, curl, and tools across the ecosystem.

    Replace the Base URL ( https://api.gate.ai/openai/v1 ) and API key to start using it.

    from openai import OpenAI
    
    client = OpenAI(
        api_key="GATEAI_API_KEY",  # get GATEAI_API_KEY from gate.ai (API Key)
        base_url="https://api.gate.ai/openai/v1",
    )
    
    completion = client.chat.completions.create(
        model="auto",
        messages=[
            {"role": "system", "content": "system prompt"},
            {"role": "user", "content": "how are you?"}
        ],
    )
    
    # get the response from LLM (role=assistant)
    print(completion.choices[0].message.content)

    Response example:

    {
        "id": "243c850e-214c-431e-977f-ebaf4aa95f56",
        "choices": [
            {
                "index": 0,
                "message": {
                    "role": "assistant",
                    "content": "Hello! Nice to meet you. How can I help you?"
                },
                "finish_reason": "stop"
            }
        ],
        "created": 1773408946,
        "model": "deepseek.v3-v1:0",
        "object": "chat.completion",
        "usage": {
            "prompt_tokens": 5,
            "completion_tokens": 15,
            "total_tokens": 20
        }
    }

    Claude Code CLI Setup

    Create a Gate.AI API Key

    1. Open gate.aiDashboard → API Keys, create and copy a key starting with sk-or-v1-…

    2. Confirm your account has sufficient balance

    Network connectivity check

    Replace GATEAI_API_KEY with your key:

    export GATEAI_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"

    Anthropic-compatible endpoint (Claude Code):

    curl -s -o /dev/null -w "%{http_code}" \
      -H "x-api-key: $GATEAI_API_KEY" \
      -H "content-type: application/json" \
      -H "anthropic-version: 2023-06-01" \
      -d '{"model":"anthropic/claude-sonnet-4.6","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}' \
      https://api.gate.ai/anthropic/v1/messages
    • Returns 200: gateway is reachable; proceed with install and configuration

    • Returns 401: invalid or expired key — check the dashboard

    • Connection timeout: check local network or DNS; do not use https://api.gate.ai/v1

    Install Claude Code CLI

    macOS / Linux / WSL (recommended):

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

    Or with npm:

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

    If npm install fails

    This is usually caused by registry.npmjs.org timeouts or instability — unrelated to the Gate.AI gateway. Try one of the following:

    Option A: one-off install with a mirror (try first)

    npm install -g @openai/codex --registry=https://registry.npmmirror.com
    npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

    Option B: set mirror globally

    # Use npmmirror (common in China)
    npm config set registry https://registry.npmmirror.com
    
    # Verify registry
    npm config get registry
    
    # Reinstall
    npm install -g @openai/codex
    npm install -g @anthropic-ai/claude-code

    Option C: current shell session only

    export NPM_CONFIG_REGISTRY=https://registry.npmmirror.com
    npm install -g @openai/codex
    SymptomFix
    ETIMEDOUT / ECONNRESETSwitch mirror (Option A or B) and retry
    EACCES permission errorConfigure npm global prefix: mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global, and add export PATH=~/.npm-global/bin:$PATH to ~/.zshrc
    command not found: claude / codexInstalled but PATH not updated: restart the terminal, or confirm bin under npm config get prefix is on PATH

    Configure model

    Replace all sk-or-v1-your-key placeholders with your real key. No need to repeat unless you change the key or model.

    mkdir -p ~/.claude
    
    cat > ~/.claude/settings.json <<'EOF'
    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.gate.ai/anthropic",
        "ANTHROPIC_API_KEY": "sk-or-v1-your-key",
        "ANTHROPIC_MODEL": "anthropic/claude-sonnet-4.6"
      },
      "includeCoAuthoredBy": false
    }
    EOF
    
    # Clear old Anthropic / proxy sessions to avoid auth conflicts
    claude /logout 2>/dev/null || true
    unset ANTHROPIC_AUTH_TOKEN

    Store credentials only in settings.json. If ~/.zshrc still has ANTHROPIC_AUTH_TOKEN or a duplicate ANTHROPIC_API_KEY, comment or remove them.

    Verify setup

    In your project directory, start the CLI for AI-assisted coding in the terminal.

    Run claude

    claude

    First check: run /status and confirm Base URL is https://api.gate.ai/anthropic and auth token is ANTHROPIC_API_KEY.

    Advanced configuration

    Auth conflict

    If you see Auth conflict: Both a token (ANTHROPIC_AUTH_TOKEN) and an API key (ANTHROPIC_API_KEY) are set:

    ScenarioFix
    Previously logged in via Anthropic OAuth / local proxyRun claude /logout, then start claude again
    Both token and key configured in shell and settingsKeep only ANTHROPIC_API_KEY; comment out ANTHROPIC_AUTH_TOKEN in ~/.zshrc

    Alternative configuration

    Shell environment variables (do not duplicate settings.json):

    export ANTHROPIC_BASE_URL="https://api.gate.ai/anthropic"
    export ANTHROPIC_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"
    export ANTHROPIC_MODEL="anthropic/claude-sonnet-4.6"

    Project-level settings (share structure; never commit real keys):

    PathPurpose
    .claude/settings.jsonProject-level, committable (no secrets)
    .claude/settings.local.jsonLocal project key; add to .gitignore

    Model environment variables

    Add to the env block in settings.json:

    VariablePurposeExample
    ANTHROPIC_DEFAULT_SONNET_MODELSonnet-tier tasksanthropic/claude-sonnet-4.6
    ANTHROPIC_DEFAULT_OPUS_MODELOpus-tier tasksanthropic/claude-opus-4.6
    ANTHROPIC_DEFAULT_HAIKU_MODELHaiku-tier tasksanthropic/claude-haiku-4.5
    CLAUDE_CODE_SUBAGENT_MODELSub-agent tasksanthropic/claude-sonnet-4.6

    Full list: model catalog. If auto fails, use an explicit model ID.

    Restore direct Anthropic (optional)

    env -u ANTHROPIC_BASE_URL -u ANTHROPIC_API_KEY claude

    Troubleshooting

    Common Base URL mistakes

    # ❌ Wrong (missing /anthropic prefix, 404)
    https://api.gate.ai/v1
    https://api.gate.ai/v1/chat/completions
    
    # ❌ Wrong (do not use full API path in Claude config)
    https://api.gate.ai/anthropic/v1/messages
    https://api.gate.ai/anthropic/messages
    
    # ✅ Correct
    https://api.gate.ai/anthropic/v1
    https://api.gate.ai/anthropic          # Claude Code CLI
    https://api.gate.ai/anthropic/v1/messages  # curl key check (Anthropic)
    https://api.gate.ai/openai/v1/responses    # curl key check (Codex)
    • /openai/v1/chat/completions works, but Codex must use the Responses API. On 404 for /responses, check wire_api = "responses", not the URL.

    • /openai/v1/models does not validate keys (invalid keys may still return 200). Use the curl endpoints above to verify keys.

    Quick reference

    SymptomTypeSuggestion
    Auth conflict warningAuth conflictRun claude /logout; keep only ANTHROPIC_API_KEY; remove or comment ANTHROPIC_AUTH_TOKEN
    401 / auth failureAuth errorCheck the key is correct and not expired
    404 on URLPath errorClaude → https://api.gate.ai/anthropic; Codex → https://api.gate.ai/openai/v1. Do not use https://api.gate.ai/v1/...
    Model not foundModel ID errorUse provider/model-name format (e.g. anthropic/claude-sonnet-4.6, openai/gpt-5.2); see the model catalog
    Still connecting to official domainConfig not appliedUse user-level config: Claude → ~/.claude/settings.json; Codex → ~/.codex/config.toml (project .codex/config.toml cannot override gateway settings)
    Shows offlineCLI behaviorDoes not affect main chat; safe to ignore
    402 / 429Quota / rate limitTop up or check key budget and rate limits
    npm install failsNetwork / permissionsSee "If npm install fails"

    Codex CLI Setup

    Create a Gate.AI API Key

    1. Open gate.aiDashboard → API Keys, create and copy a key starting with sk-or-v1-…

    2. Confirm your account has sufficient balance

    Network connectivity check

    Replace GATEAI_API_KEY with your key:

    export GATEAI_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"

    OpenAI-compatible endpoint (Codex / standard API):

    curl -s -o /dev/null -w "%{http_code}" \
      -H "Authorization: Bearer $GATEAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"model":"openai/gpt-5.2","input":"hi","max_output_tokens":16}' \
      https://api.gate.ai/openai/v1/responses
    • Returns 200: gateway is reachable; proceed with install and configuration

    • Returns 401: invalid or expired key — check the dashboard

    • Connection timeout: check local network or DNS; do not use https://api.gate.ai/v1

    Install Codex CLI

    npm install -g @openai/codex

    Or

    curl -fsSL https://chatgpt.com/codex/install.sh | sh

    If you use Homebrew

    brew install --cask codex

    Verify: codex --version

    If npm install fails

    This is usually caused by registry.npmjs.org timeouts or instability — unrelated to the Gate.AI gateway. Try one of the following:

    Option A: one-off install with a mirror (try first)

    npm install -g @openai/codex --registry=https://registry.npmmirror.com
    npm install -g @anthropic-ai/claude-code --registry=https://registry.npmmirror.com

    Option B: set mirror globally

    # Use npmmirror (common in China)
    npm config set registry https://registry.npmmirror.com
    
    # Verify registry
    npm config get registry
    
    # Reinstall
    npm install -g @openai/codex
    npm install -g @anthropic-ai/claude-code

    Option C: current shell session only

    export NPM_CONFIG_REGISTRY=https://registry.npmmirror.com
    npm install -g @openai/codex
    SymptomFix
    ETIMEDOUT / ECONNRESETSwitch mirror (Option A or B) and retry
    EACCES permission errorConfigure npm global prefix: mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global, and add export PATH=~/.npm-global/bin:$PATH to ~/.zshrc
    command not found: claude / codexInstalled but PATH not updated: restart the terminal, or confirm bin under npm config get prefix is on PATH

    Configure model

    Replace all sk-or-v1-your-key placeholders with your real key. No need to repeat unless you change the key or model.

    mkdir -p ~/.codex
    
    cat > ~/.codex/config.toml <<'EOF'
    model_provider = "gateai"
    model = "openai/gpt-5.2"
    
    [model_providers.gateai]
    name = "Gate.AI"
    base_url = "https://api.gate.ai/openai/v1"
    env_key = "GATEAI_API_KEY"
    wire_api = "responses"
    requires_openai_auth = false
    EOF
    
    grep -q 'GATEAI_API_KEY=' ~/.zshrc 2>/dev/null || cat >> ~/.zshrc <<'EOF'
    
    # Gate.AI for Codex CLI
    export GATEAI_API_KEY="sk-or-v1-your-key"
    EOF
    
    source ~/.zshrc

    Codex gateway settings must be in user-level ~/.codex/config.toml. Project-level .codex/config.toml cannot override these values.

    Verify setup

    In your project directory, start the CLI for AI-assisted coding in the terminal.

    Run codex

    codex

    If you get a normal reply without 401 / 404, routing through Gate.AI succeeded.

    Advanced configuration

    Config reference

    FieldDescriptionExample
    model_providerProvider name"gateai"
    modelGate.AI model ID"openai/gpt-5.2"
    base_urlGate OpenAI-compatible endpointhttps://api.gate.ai/openai/v1
    env_keyAPI key environment variable"GATEAI_API_KEY"
    wire_apiCodex protocol type"responses"
    requires_openai_authWhen Gate key is not OpenAI official formatfalse
    model_reasoning_effortReasoning effort (optional)"low" / "medium" / "high"

    Alternative configuration

    Built-in OpenAI provider (try if Option A auth fails)

    model = "openai/gpt-5.2"
    openai_base_url = "https://api.gate.ai/openai/v1"

    Environment variable: export OPENAI_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"

    Temporary CLI override

    export GATEAI_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"
    codex --config openai_base_url='"https://api.gate.ai/openai/v1"' --config model='"openai/gpt-5.2"'

    Switch model

    Edit model in ~/.codex/config.toml, or run: codex --model openai/gpt-5.2

    Restore direct OpenAI (optional)

    Remove Gate-related settings from ~/.codex/config.toml and unset GATEAI_API_KEY.

    Troubleshooting

    Common Base URL mistakes

    # ❌ Wrong (missing /openai prefix, 404)
    https://api.gate.ai/v1
    https://api.gate.ai/v1/chat/completions
    
    # ❌ Wrong (do not use full API path in Codex config)
    https://api.gate.ai/openai/v1/messages
    https://api.gate.ai/openai/messages
    
    # ✅ Correct
    https://api.gate.ai/openai/v1          # Codex CLI
    https://api.gate.ai/anthropic/v1/messages  # curl key check (Anthropic)
    https://api.gate.ai/openai/v1/responses    # curl key check (Codex)
    • /openai/v1/chat/completions works, but Codex must use the Responses API. On 404 for /responses, check wire_api = "responses", not the URL.

    • /openai/v1/models does not validate keys (invalid keys may still return 200). Use the curl endpoints above to verify keys.

    Quick reference

    SymptomTypeSuggestion
    401 / auth failureAuth errorCheck the key is correct and not expired; for Codex confirm requires_openai_auth = false
    404 on URLPath errorClaude → https://api.gate.ai/anthropic; Codex → https://api.gate.ai/openai/v1. Do not use https://api.gate.ai/v1/...
    404 on /responsesProtocol errorBase URL may be correct but Responses API not used. Check ~/.codex/config.toml: wire_api = "responses", base_url = "https://api.gate.ai/openai/v1"
    curl /models returns 200 but CLI still 401Wrong key check/openai/v1/models does not validate keys. Use /openai/v1/responses or /anthropic/v1/messages instead
    Model not foundModel ID errorUse provider/model-name format (e.g. anthropic/claude-sonnet-4.6, openai/gpt-5.2); see the model catalog
    Still connecting to official domainConfig not appliedUse user-level config: Claude → ~/.claude/settings.json; Codex → ~/.codex/config.toml (project .codex/config.toml cannot override gateway settings)
    402 / 429Quota / rate limitTop up or check key budget and rate limits
    npm install failsNetwork / permissionsSee "If npm install fails"

    Cursor Setup

    Prerequisites

    • Cursor is installed
    • You have a Gate.AI API Key

    Step 1: Open Cursor Settings

    Open the top-right menu → Settings.

    Screenshot of the Cursor Settings entry point
    Reference: open Cursor Settings.

    Step 2: Open Models Settings

    In the left sidebar:

    1. Find and open Models
    2. Click View All Models
    3. Scroll to the bottom and click Add Custom Model
    Screenshot of the Cursor Models settings menu
    Reference: open Models settings.
    Screenshot of Add Custom Model in Cursor
    Reference: click Add Custom Model.

    Step 3: Add Configuration

    Fill in the integration information:

    ItemDescription
    Model IDCopy a model ID from the model marketplace, such as deepseek/deepseek-v3.2. Do not use auto.
    OpenAI API KeyTurn on the switch and enter your Gate.AI API Key.
    OpenAI Base URLTurn on the switch and enter https://api.gate.ai/openai/v1.
    Screenshot of API Key and Base URL settings in Cursor
    Reference: enter API Key and Base URL.

    Step 4: Save and Close Settings

    After finishing the configuration, save it and close Settings.

    Step 5: Use Gate.AI in Cursor

    In Chat, Composer, Agent, and other conversation surfaces, search for or choose the model you just added from the model selector.

    Screenshot of the Cursor model selector
    Reference: choose the model you just added from the model selector.

    FAQ

    SymptomFix
    401 / Connection failedConfirm the Base URL is https://api.gate.ai/openai/v1, the API Key is valid, and the account has available balance.
    Model unavailableConfirm the model ID comes from the model marketplace, uses the provider/model format, and is not auto.
    Model not found in the listConfirm the Settings page was saved; restart Cursor and try again.

    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-or-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-or-v1-…)

    Option A: Current terminal session (temporary)

    export ANTHROPIC_BASE_URL="https://api.gate.ai/anthropic"
    export ANTHROPIC_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"
    claude

    Option B: Shell profile

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

    export ANTHROPIC_BASE_URL="https://api.gate.ai/anthropic"
    export ANTHROPIC_API_KEY="sk-or-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:

    {
      "env": {
        "ANTHROPIC_BASE_URL": "https://api.gate.ai/anthropic",
        "ANTHROPIC_API_KEY": "sk-or-v1-xxxxxxxxxxxxxxxx"
      }
    }

    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:

    env -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

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

    export ANTHROPIC_DEFAULT_SONNET_MODEL="anthropic/claude-sonnet-4.6"
    export ANTHROPIC_DEFAULT_OPUS_MODEL="anthropic/claude-opus-4.6"
    export 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):

    export ANTHROPIC_CUSTOM_MODEL_OPTION="anthropic/claude-sonnet-4.6"
    export 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:
    claude
    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

    Claude Desktop Setup

    Prerequisites

    Step 1: Enable Developer Mode

    1. Launch Claude Desktop. You do not need to sign in with an Anthropic account.
    2. From the menu bar, choose Help → Troubleshooting → Enable Developer Mode.
    Screenshot showing the Enable Developer Mode menu item in Claude Desktop
    Reference: enable Developer Mode from Help → Troubleshooting.

    After enabling it, the Developer menu appears in the menu bar.

    Screenshot showing the Developer menu in Claude Desktop
    Reference: the Developer menu appears after Developer Mode is enabled.

    Step 2: Open Third-Party Inference Settings

    From the menu bar, choose Developer → Configure Third-Party Inference…

    Screenshot showing the Configure Third-Party Inference menu item in Claude Desktop
    Reference: open Configure Third-Party Inference from the Developer menu.

    Step 3: Enter Gate.AI Credentials and Models

    1. Choose Gateway and Static API key, then enter your Gate.AI credentials.
      After filling them in, click Test connection to test the connection.
    Screenshot of Gateway and Static API key configuration in Claude Desktop
    Reference: enter Gateway and Static API key configuration.
    1. Turn on Model discovery.
      After enabling it, you can click Test connection again.
    Screenshot of the Model discovery switch in Claude Desktop
    Reference: turn on Model discovery.
    1. Click Apply Changes to save.

    Step 4: Restart and Launch

    1. Fully quit Claude Desktop, including the app process, then reopen it.
    2. On the launch page, choose Continue with Gateway. No Anthropic account is required.

    Step 5: Verify

    The connection is successful when the model picker shows available models.

    FAQ

    SymptomFix
    Connection failed / 401Confirm the Base URL is https://api.gate.ai/anthropic/, Auth scheme is x-api-key, and the API key is valid.
    Continue with Gateway does not appearConfirm you clicked Apply Changes and fully quit and restarted Claude Desktop.
    No models are shownConfirm your Gate.AI account has available balance, and check that Model discovery is enabled.

    Hermes Setup

    Prerequisites

    • Create an API key in the Gate.AI Console.
    • If you use auto routing, enable it under Settings → Routing in the console.

    Option 1: Terminal setup

    1. Choose model and custom endpoint

    Run in your terminal:

    hermes model

    In the menu, choose Custom endpoint and fill in the fields:

    ItemValue
    API base URLhttps://api.gate.ai/openai/v1
    API keyYour Gate.AI API key
    Modelauto (recommended for auto routing), or the full model ID from the console (e.g. deepseek/deepseek-v3.2)

    If you are asked for context length, press Enter to leave it blank (Hermes will detect it).

    2. (Optional) Local web dashboard

    To edit configuration in the browser, run:

    hermes dashboard

    3. Verify

    hermes chat "Hello"

    Success means the request reached Gate.AI and smart routing or your chosen model returned a result.

    You can also run hermes doctor to verify the connection.

    Option 2: Edit configuration files

    1. File locations

    macOS / Linux

    • ~/.hermes/config.yaml, main config (model, provider, base_url, api_key, etc.)
    • ~/.hermes/.env, secrets and env vars (recommended)

    Windows

    • C:\Users\<username>\.hermes\config.yaml
    • C:\Users\<username>\.hermes\.env

    2. Save the API key in .env (pick one)

    Option A (same name as Gate.AI)

    # Gate.AI API 密钥
    GATEAI_API_KEY=sk-or-v1_xxxxxxxxxxxxxxxxxxxxx

    Option B (common Hermes custom-endpoint convention)

    If model.api_key is not set for a custom endpoint, Hermes falls back to OPENAI_API_KEY. Put your Gate.AI key there:

    OPENAI_API_KEY=sk-or-v1_xxxxxxxxxxxxxxxxxxxxx

    3. Configure model in config.yaml

    Auto routing (auto)

    model:
      default: auto
      provider: custom
      base_url: https://api.gate.ai/openai/v1
      api_key: ${GATEAI_API_KEY}

    If you use Option B, leave api_key blank or remove it so Hermes uses OPENAI_API_KEY.

    Hermes expands ${VAR} when loading config (variables must exist in the environment, usually from ~/.hermes/.env).

    Fixed model example

    The model ID must match the Gate.AI model list.

    model:
      default: deepseek/deepseek-v3.2
      provider: custom
      base_url: https://api.gate.ai/openai/v1
      api_key: ${GATEAI_API_KEY}

    4. Verify after saving

    After saving, run hermes chat "Hello" to verify the Gate.AI connection.

    Multiple routes / models

    If you need multiple logical routes under one Gate.AI key (e.g. one with auto and one fixed to deepseek/deepseek-v3.2), add custom_providers in config.yaml (names: letters, digits, hyphens; e.g. gateai-auto):

    model:
      default: auto
      provider: custom
      base_url: https://api.gate.ai/openai/v1
      api_key: ${GATEAI_API_KEY}
    
    custom_providers:
      - name: gateai-auto
        base_url: https://api.gate.ai/openai/v1
        api_key: ${GATEAI_API_KEY}
        model: auto
    
      - name: gateai-deepseek
        base_url: https://api.gate.ai/openai/v1
        api_key: ${GATEAI_API_KEY}
        model: deepseek/deepseek-v3.2

    How to switch

    1. Terminal: run hermes model again and pick the named route or Custom endpoint.
    2. In chat (TUI): use the /model syntax from the Hermes docs, for example:
    /model custom:gateai-auto:auto
    /model custom:gateai-deepseek:deepseek/deepseek-v3.2

    (Names follow custom_providers[].name; format is custom:<profile name>:<model id>.)

    FAQ

    Only some models work

    Confirm model.provider is custom, and Base URL is https://api.gate.ai/openai/v1. If OpenAI-compatible models work but others do not, check model IDs and routing settings.

    401 / invalid API key

    Check the key is copied correctly and not expired; after editing .env, restart running hermes and hermes gateway before retrying.

    Model not found or empty reply

    • Model ID matches the console (e.g. deepseek/deepseek-v3.2).
    • Auto routing is enabled in the Gate.AI console.
    • Run hermes doctor to inspect config and connectivity.

    QClaw Setup

    If you already have QClaw installed, follow these steps to connect Gate.AI.

    Configure in chat

    1. In the chat, send the message below. Replace the apiKey value with your Gate.AI API key.

    Help me add a new provider
    Name: Gate.AI
    apiKey: sk-or-v1-xxxxxxxxxxxxxxxx
    baseUrl: https://api.gate.ai/openai/v1
    Model: auto

    QClaw will add the provider and restart automatically.

    2. Verify

    Ask: “Help me verify that my Gate.AI configuration is working.” The assistant should reply with something like “Gate.AI provider was added successfully!” (exact wording may vary.)

    3. Switch to Gate.AI

    Ask: “Switch to auto under Gate.AI.” The assistant should reply with something like “Switched successfully!” (exact wording may vary.)


    AutoClaw Setup

    1. Open the configuration entry

    Click Preferences in the bottom-left, go to Models & API, then click Add custom model.

    2. Add a model

    • Set the provider to Custom.
    • Enter a Gate.AI-supported model ID, e.g. deepseek/deepseek-v3.2.
    • Enter a display name, e.g. Gate.AI(deepseek-v3.2).
    • Enter your API Key, e.g. sk-or-v1-xxxxxxxxxxxxxxxx.
    • Base URL: https://api.gate.ai/openai/v1

    3. Test the configuration

    Click the connection test. If you see “Test successful”, the setup is correct.

    4. Use the model

    • Click Add. After it saves, return to the app.
    • Below the chat input, switch the model to your configured Gate.AI(deepseek-v3.2) to use it.

    API Reference

    General Chat API Reference

    FieldValue
    Base URLhttps://api.gate.ai/openai/v1
    AuthAuthorization: Bearer <API_KEY>
    FormatOpenAI-compatible
    PricingPay-as-you-go

    Note: The API path is /openai/v1 (not /v1).

    Endpoints

    MethodPathDescription
    POST/chat/completionsChat completions (streaming supported)
    GET/modelsList available models

    Seedance Video Generation API Reference

    FieldValue
    Base URLhttps://api.gate.ai
    AuthAuthorization: Bearer <API_KEY>

    Submit Video Task

    POST/api/v1/videos

    Submit an async video generation job. Returns 202 Accepted with job_id for polling. Pass Idempotency-Key for safe retries.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format
    Idempotency-KeyheaderstringNoIdempotency key for safe retries — same key returns the existing job

    Request Body

    NameTypeRequiredDescription
    modelstringYesModel ID, use bytedance/seedance-2.0
    promptstringYesVideo prompt; describe subject, motion, scene, camera, and style. Limits vary by model: Sora 500 characters, Hailuo 2000 characters, Wan T2V 1500 characters, and Wan I2V 800 characters. Gate.AI does not enforce a hard limit; over-limit prompts are rejected upstream and surfaced as 502 / 503.
    durationintegerNoDuration in seconds: 4–15
    resolutionstringNoOutput resolution: 480p, 720p, or 1080p
    aspect_ratiostringNoAspect ratio: 16:9, 4:3, 1:1, 3:4, 9:16, 21:9, or adaptive
    generate_audiobooleanNoWhether to generate audio
    seedintegerNoRandom seed, -1 to 4294967295; same seed does not guarantee identical output
    sizestringNoExact output size, e.g. 1280x720
    input_referencesarrayNoOptional reference media array for image-to-video, first/last frame driving, video style transfer, or audio-driven generation
    input_references[].typestringYesReference media type: image, video, or audio. Must match the selected role
    input_references[].urlstringYesHTTPS URL of the reference media
    input_references[].rolestringYesReference purpose: first_frame, last_frame, reference_video, or reference_audio. first_frame/last_frame allow one image each; last_frame requires first_frame
    metadataobjectNoBusiness pass-through fields for auditing or source tagging
    webhook_urlstringNoCallback URL invoked when the task completes or fails

    Example

    {
      "model": "bytedance/seedance-2.0",
      "prompt": "A golden retriever running on a sunny beach, cinematic camera movement",
      "duration": 6,
      "resolution": "720p",
      "aspect_ratio": "16:9",
      "generate_audio": false,
      "seed": -1,
      "input_references": [
        {
          "type": "image",
          "url": "https://cdn.example.com/portrait.jpg",
          "role": "first_frame"
        }
      ],
      "metadata": {
        "source": "playground"
      },
      "webhook_url": "https://example.com/webhooks/gateai-video"
    }

    Response Fields

    NameTypeDescription
    job_idstringUnique job ID
    statusstringTask status: pending / in_progress / completed / failed
    modelstringModel used
    status_urlstringURL to poll task status
    messagestringServer message
    current_balancestringCurrent account balance (USD)
    estimated_coststringEstimated cost
    pre_deduct_amountstringPre-deducted display amount
    balance_after_estimatestringBalance after applying estimated cost
    currencystringCurrency, currently USD
    billing_noticestringBilling notice

    Response Example

    {
      "code": 200,
      "msg": "",
      "data": {
        "job_id": "video_abc123",
        "status": "in_progress",
        "model": "bytedance/seedance-2.0",
        "status_url": "https://api.gate.ai/api/v1/videos/video_abc123",
        "message": "视频任务已提交,请调用 status_url 查询生成进度。",
        "current_balance": "100.0000000000",
        "estimated_cost": "1.0800000000",
        "pre_deduct_amount": "1.0800000000",
        "balance_after_estimate": "98.9200000000",
        "currency": "USDT",
        "billing_notice": "视频生成完成后按实际任务结果扣款,提交后请保持余额充足。"
      }
    }

    Response

    StatusMeaningDescriptionSchema
    202AcceptedTask accepted and queued. Returns job_id for status polling.VideoSubmitResponse
    400Bad RequestParameter errorErrorResponse
    401UnauthorizedNot logged in or token invalidErrorResponse
    402Payment RequiredInsufficient balance. Response includes estimated cost and current balance.ErrorResponse
    429Too Many RequestsToo many requests. Please slow down.ErrorResponse
    500Internal Server ErrorInternal server errorErrorResponse

    Query Task Status

    GET/api/v1/videos/{job_id}

    Poll job status, progress, and billing info. Returns download_url when status is completed.

    Request Parameters

    NameInTypeRequiredDescription
    job_idpathstringYesVideo task ID
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>

    Response Fields

    NameTypeDescription
    job_idstringUnique job ID
    statusstringTask status: pending / in_progress / completed / failed
    modelstringModel used
    status_urlstringURL to poll task status
    download_urlstringVideo download URL (appears when status is completed)
    durationintegerVideo duration in seconds
    resolutionstringOutput resolution
    aspect_ratiostringAspect ratio
    generate_audiobooleanWhether audio is included
    estimated_coststringEstimated cost
    billed_coststringActual billed amount
    billing_statusstringBilling status: pre_deducted or settled
    expires_atstring(ISO 8601)Video file expiration time
    created_atstring(ISO 8601)Task creation time
    completed_atstring(ISO 8601)Task completion time

    Response Example

    {
      "code": 200,
      "msg": "",
      "data": {
        "job_id": "video_abc123",
        "status": "completed",
        "model": "bytedance/seedance-2.0",
        "status_url": "https://api.gate.ai/api/v1/videos/video_abc123",
        "download_url": "https://api.gate.ai/api/v1/videos/video_abc123/content",
        "duration": 6,
        "resolution": "720p",
        "aspect_ratio": "16:9",
        "generate_audio": false,
        "estimated_cost": "1.0800000000",
        "billed_cost": "1.0800000000",
        "billing_status": "settled",
        "expires_at": "2026-06-26T05:00:00Z",
        "created_at": "2026-05-27T05:00:00Z",
        "completed_at": "2026-05-27T05:03:00Z"
      }
    }

    Response

    StatusMeaningDescriptionSchema
    200OKSuccessVideoStatusResponse
    401UnauthorizedNot logged in or token invalidErrorResponse
    404Not FoundJob not found, or job does not belong to this API key.ErrorResponse
    500Internal Server ErrorInternal server errorErrorResponse

    Download Video

    GET/api/v1/videos/{job_id}/content

    Authenticate and redirect (302) to the temporary video file URL.

    Request Parameters

    NameInTypeRequiredDescription
    job_idpathstringYesVideo task ID
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>

    Response Example

    HTTP/1.1 302 Found
    Location: https://cdn.example.com/videos/video_abc123.mp4?expires=1780000000

    Response

    StatusMeaningDescriptionSchema
    302FoundRedirects to temporary video download URL.
    401UnauthorizedNot logged in or token invalidErrorResponse
    404Not FoundJob not found, or job does not belong to this API key.ErrorResponse
    409ConflictTask not yet completed; video is not available for download.ErrorResponse
    410GoneVideo content has expired and is no longer available.ErrorResponse
    500Internal Server ErrorInternal server errorErrorResponse

    Reference Image API Reference

    Use the Gate.AI image-to-image endpoint to upload a reference image and generate or edit an image. This endpoint uses multipart/form-data and synchronously returns image URLs and billing details; usage.input_tokens includes image_tokens counted from the reference image.

    FieldValue
    Base URLhttps://api.gate.ai/openai/v1
    AuthAuthorization: Bearer <API_KEY>
    FormatOpenAI-compatible; uses a multipart/form-data request body

    Note: Image endpoints live under /openai/v1. Generated data[].url values are short-lived S3 presigned URLs, so download or persist them promptly. Stored objects have a 30-day TTL.

    Generate Images from a Reference Image

    POST/images/edits

    Upload a reference image with multipart/form-data to synchronously generate or edit an image. usage.input_tokens includes image_tokens counted from the reference image.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: multipart/form-data

    Request Body

    NameTypeRequiredDescription
    modelstringYesImage model ID, such as gpt-image-1, qwen-image-2.0-pro, or seedream-4.0. Missing model returns 400 model is required
    imagefileYesReference image file. gpt-image-1 requires PNG, under 4 MB, square; without mask, it must include an alpha channel as the mask
    maskfileNoPNG mask. Transparent areas are edited, and dimensions must match image
    promptstringYesEdit prompt, up to 1000 characters
    nintegerNoNumber of images to generate, 1-10, default 1. Multiple images are billed per image
    sizestringNoOutput size. gpt-image-1 supports 256x256, 512x512, or 1024x1024, and this is used for cost estimation
    response_formatstringNourl or b64_json. gpt-image-1 does not support this parameter and may reject it upstream

    Example

    model=gpt-image-1
    prompt=Add a yellow border and a small sun in the corner
    size=1024x1024
    image=@./input.png

    Response Fields

    NameTypeDescription
    createdintegerGeneration timestamp in seconds
    dataarrayResult array, length equals n
    data[].urlstringImage S3 presigned URL, short-lived, with a 30-day stored object TTL
    usageobjectUsage. OpenAI models return token details; Qwen models return width, height, and image_count
    model_extend.coststringActual billed amount in USD; billing is based on this value
    model_extend.line_itemsarrayBilling line items. Token billing includes input/output/cache; per-image billing includes billing_unit, rate_usd_per_image, and resolution_tier
    model_extend.providerstringActual upstream provider, such as openai or qwen
    size / quality / output_format / backgroundstringInput fields echoed by some models
    modelstringOnly echoed at the top level for Qwen models

    Response Example

    {
      "created": 1781604390,
      "data": [
        {
          "url": "https://ai-gateway-file.s3.ap-northeast-1.amazonaws.com/multimodal/image/2026/06/16/example-edit-0.png?X-Amz-Expires=600&X-Amz-Signature=..."
        }
      ],
      "size": "1024x1024",
      "quality": "low",
      "output_format": "png",
      "usage": {
        "input_tokens": 220,
        "input_tokens_details": {
          "image_tokens": 194,
          "text_tokens": 26
        },
        "output_tokens": 272,
        "total_tokens": 492
      },
      "model_extend": {
        "cost": "0.009804",
        "provider": "openai",
        "total_tokens": "492"
      }
    }

    Response

    StatusMeaningDescriptionSchema
    200OKSuccess. Returns image results and billing information synchronously.ImageResponse
    400Bad RequestMalformed request body, invalid JSON, or missing model / prompt.OpenAIErrorResponse
    401UnauthorizedAPI key is invalid or missing.OpenAIErrorResponse
    402Payment RequiredInsufficient balance. Response includes current balance and estimated cost.InsufficientBalanceResponse
    404Not FoundModel not found, or the image endpoint is not enabled.OpenAIErrorResponse
    413Payload Too LargeRequest body too large. Default limit is 8 MiB.OpenAIErrorResponse
    429Too Many RequestsToo many requests. Please slow down.OpenAIErrorResponse
    500Internal Server ErrorInternal server error.OpenAIErrorResponse
    502Bad GatewayUpstream image service failed.OpenAIErrorResponse

    Text-to-Image API Reference

    Use the Gate.AI text-to-image endpoint to call image models from OpenAI, Qwen, Seedream, and other providers. This endpoint uses a JSON request body and synchronously returns image URLs and billing details, with no job_id polling or webhook.

    FieldValue
    Base URLhttps://api.gate.ai/openai/v1
    AuthAuthorization: Bearer <API_KEY>
    FormatOpenAI-compatible; uses a JSON request body

    Note: Image endpoints live under /openai/v1. Generated data[].url values are short-lived S3 presigned URLs, so download or persist them promptly. Stored objects have a 30-day TTL.

    Generate Images from Text

    POST/images/generations

    Generate images synchronously from a text prompt. Successful responses use the OpenAI-compatible image result shape, with data[].url pointing to the generated image.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: application/json

    Request Body

    NameTypeRequiredDescription
    modelstringYesImage model ID, such as gpt-image-1, qwen-image-2.0-pro, or seedream-4.0. Missing model returns 400 model is required
    promptstringYesImage text prompt. gpt-image-1 allows up to 32000 characters
    nintegerNoNumber of images to generate, 1-10, default 1. Multiple images are billed per image
    sizestringNoOutput size. gpt-image-1 supports 1024x1024, 1536x1024, 1024x1536, or auto, and this is used for cost estimation
    response_formatstringNourl or b64_json. gpt-image-1 does not support this parameter and may reject it upstream
    streambooleanNoPass-through field. The current image path is synchronous and does not route by this value

    Example

    {
      "model": "gpt-image-1",
      "prompt": "A golden retriever running on a sunny beach, cinematic",
      "n": 1,
      "size": "1024x1024"
    }

    Response Fields

    NameTypeDescription
    createdintegerGeneration timestamp in seconds
    dataarrayResult array, length equals n
    data[].urlstringImage S3 presigned URL, short-lived, with a 30-day stored object TTL
    usageobjectUsage. OpenAI models return token details; Qwen models return width, height, and image_count
    model_extend.coststringActual billed amount in USD; billing is based on this value
    model_extend.line_itemsarrayBilling line items. Token billing includes input/output/cache; per-image billing includes billing_unit, rate_usd_per_image, and resolution_tier
    model_extend.providerstringActual upstream provider, such as openai or qwen
    size / quality / output_format / backgroundstringInput fields echoed by some models
    modelstringOnly echoed at the top level for Qwen models

    Response Example

    {
      "created": 1781604363,
      "data": [
        {
          "url": "https://ai-gateway-file.s3.ap-northeast-1.amazonaws.com/multimodal/image/2026/06/16/example-0.png?X-Amz-Expires=600&X-Amz-Signature=..."
        }
      ],
      "size": "1024x1024",
      "quality": "low",
      "output_format": "png",
      "background": "opaque",
      "usage": {
        "input_tokens": 10,
        "output_tokens": 196,
        "total_tokens": 206,
        "output_tokens_details": {
          "image_tokens": 196,
          "text_tokens": 0
        }
      },
      "model_extend": {
        "cost": "0.006322",
        "provider": "openai",
        "total_tokens": "206",
        "line_items": [
          {
            "kind": "uncached_input",
            "tokens": 10,
            "rate_usd_per_million": "5.0000000000",
            "amount_usd": "0.0000500000"
          },
          {
            "kind": "output",
            "tokens": 196,
            "rate_usd_per_million": "32.0000000000",
            "amount_usd": "0.0062720000"
          }
        ]
      }
    }

    Response

    StatusMeaningDescriptionSchema
    200OKSuccess. Returns image results and billing information synchronously.ImageResponse
    400Bad RequestMalformed request body, invalid JSON, or missing model / prompt.OpenAIErrorResponse
    401UnauthorizedAPI key is invalid or missing.OpenAIErrorResponse
    402Payment RequiredInsufficient balance. Response includes current balance and estimated cost.InsufficientBalanceResponse
    404Not FoundModel not found, or the image endpoint is not enabled.OpenAIErrorResponse
    413Payload Too LargeRequest body too large. Default limit is 8 MiB.OpenAIErrorResponse
    429Too Many RequestsToo many requests. Please slow down.OpenAIErrorResponse
    500Internal Server ErrorInternal server error.OpenAIErrorResponse
    502Bad GatewayUpstream image service failed.OpenAIErrorResponse

    Speech-to-Text API Reference

    Upload an audio file through the Gate.AI speech-to-text endpoint and receive an OpenAI-compatible transcription result synchronously. When stream=true is set, the gateway relays upstream SSE as text/event-stream, with usage and model_extend on the final frame.

    FieldValue
    Base URLhttps://api.gate.ai/openai/v1
    AuthAuthorization: Bearer <API_KEY>
    FormatOpenAI-compatible; uploads audio with multipart/form-data

    Note: Audio endpoints live under /openai/v1. Speech-to-text and text-to-speech are synchronous capabilities: no job_id is returned and no polling is required. For default binary TTS responses, billing details are recorded in Console Generations.

    Speech to Text

    POST/audio/transcriptions

    Upload an audio file for transcription and synchronously receive text, usage, and model_extend.cost. gpt-4o-transcribe and gpt-4o-mini-transcribe are token billed; whisper-1 is typically billed by audio duration.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: multipart/form-data

    Request Body

    NameTypeRequiredDescription
    modelstringYesSpeech-to-text model ID, such as whisper-1, gpt-4o-transcribe, or gpt-4o-mini-transcribe. Availability depends on the platform catalog
    filefileYesAudio file to transcribe, such as mp3, wav, or m4a
    languagestringNoOptional language hint, such as zh, to improve transcription accuracy
    streambooleanNoSet true to return text/event-stream transcription events. The final transcript.text.done frame includes usage and model_extend

    Example

    model=gpt-4o-transcribe
    language=zh
    file=@./input.mp3

    Response Fields

    NameTypeDescription
    textstringTranscribed text
    usageobjectSpeech-to-text usage. Different models may return token usage or audio-duration usage
    usage.input_token_details.audio_tokensintegerAudio input token count for token-billed transcription models
    model_extend.coststringActual billed amount in USD. Billing is based on model_extend.cost
    model_extend.providerstringActual upstream provider, such as openai
    model_extend.line_itemsarrayBilling line items, such as input_audio, output, or duration-billed items

    Response Example

    {
      "text": "今天天气很好,我们一起去海边散步吧。",
      "usage": {
        "type": "tokens",
        "input_tokens": 14,
        "input_token_details": {
          "text_tokens": 0,
          "audio_tokens": 14
        },
        "output_tokens": 18,
        "total_tokens": 32
      },
      "model_extend": {
        "cost": "0.000180",
        "provider": "openai",
        "total_tokens": "32",
        "line_items": [
          {
            "kind": "input_audio",
            "tokens": 14,
            "rate_usd_per_million": "6.0000000000",
            "amount_usd": "0.0000840000"
          },
          {
            "kind": "output",
            "tokens": 18,
            "rate_usd_per_million": "10.0000000000",
            "amount_usd": "0.0001800000"
          }
        ]
      }
    }

    Response

    StatusMeaningDescriptionSchema
    200OKSuccess. Returns transcription text, audio data, or SSE events synchronously.AudioResponse
    400Bad RequestInvalid parameters, malformed body, or missing required fields such as model, file, or input.OpenAIErrorResponse
    401UnauthorizedAPI key is invalid or missing.OpenAIErrorResponse
    402Payment RequiredInsufficient balance.InsufficientBalanceResponse
    404Not FoundModel not found, or the audio endpoint is not enabled.OpenAIErrorResponse
    413Payload Too LargeUploaded file or request body is too large.OpenAIErrorResponse
    429Too Many RequestsToo many requests. Please slow down.OpenAIErrorResponse
    500Internal Server ErrorInternal server error.OpenAIErrorResponse
    502Bad GatewayUpstream audio service failed.OpenAIErrorResponse

    Text-to-Speech API Reference

    Submit text through the Gate.AI text-to-speech endpoint and generate audio synchronously. By default the response is binary audio; with stream_format=sse, the endpoint returns speech.audio.delta frames and a final speech.audio.done frame with usage and model_extend.

    FieldValue
    Base URLhttps://api.gate.ai/openai/v1
    AuthAuthorization: Bearer <API_KEY>
    FormatOpenAI-compatible; uses a JSON request body, returns binary audio by default, and can stream audio chunks over SSE

    Note: Audio endpoints live under /openai/v1. Speech-to-text and text-to-speech are synchronous capabilities: no job_id is returned and no polling is required. For default binary TTS responses, billing details are recorded in Console Generations.

    Text to Speech

    POST/audio/speech

    Submit text to synthesize speech and synchronously receive audio. The default response body is a binary audio stream whose Content-Type follows response_format; SSE mode returns base64 audio chunks and final billing details.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: application/json

    Request Body

    NameTypeRequiredDescription
    modelstringYesText-to-speech model ID. Currently only gpt-4o-mini-tts is supported
    inputstringYesText to synthesize
    voicestringYesVoice name, such as alloy
    response_formatstringNoOutput audio format, such as wav or mp3. Defaults to wav
    stream_formatstringNoSet to sse to return text/event-stream. speech.audio.delta frames contain base64 audio chunks, and speech.audio.done includes usage and model_extend

    Example

    {
      "model": "gpt-4o-mini-tts",
      "input": "今天天气很好,我们一起去海边散步吧。",
      "voice": "alloy",
      "response_format": "mp3"
    }

    Response Fields

    NameTypeDescription
    audio bytesbinaryDefault binary audio response data
    speech.audio.deltaSSE eventSSE audio chunk event carrying a base64-encoded audio segment
    speech.audio.doneSSE eventSSE completion event carrying usage and model_extend
    usageobjectText-to-speech usage. For binary responses it is written to backend logs; for SSE it appears on the final frame
    model_extend.coststringActual billed amount in USD. Billing is based on model_extend.cost

    Response Example

    HTTP/1.1 200 OK
    Content-Type: audio/mpeg
    
    (binary audio bytes)

    Response

    StatusMeaningDescriptionSchema
    200OKSuccess. Returns transcription text, audio data, or SSE events synchronously.AudioResponse
    400Bad RequestInvalid parameters, malformed body, or missing required fields such as model, file, or input.OpenAIErrorResponse
    401UnauthorizedAPI key is invalid or missing.OpenAIErrorResponse
    402Payment RequiredInsufficient balance.InsufficientBalanceResponse
    404Not FoundModel not found, or the audio endpoint is not enabled.OpenAIErrorResponse
    413Payload Too LargeUploaded file or request body is too large.OpenAIErrorResponse
    429Too Many RequestsToo many requests. Please slow down.OpenAIErrorResponse
    500Internal Server ErrorInternal server error.OpenAIErrorResponse
    502Bad GatewayUpstream audio service failed.OpenAIErrorResponse

    Gemini Native Protocol API Reference

    Call Gemini models through the Gate.AI Gemini native protocol. Best for apps already using Gemini contents[], parts[], and tools[] request structures.

    FieldValue
    Base URLhttps://api.gate.ai/gemini/v1beta
    AuthAuthorization: Bearer <API_KEY>
    FormatGemini native JSON request body
    Text generationPOST /models/{model}:generateContent
    Streaming generationPOST /models/{model}:streamGenerateContent?alt=sse

    Note: Gate.AI uses its own API Key. Do not use Google Gemini's ?key= query parameter.

    The Gemini native protocol selects the model via {model} in the URL path, for example POST /models/gemini-2.5-pro:generateContent. Do not pass model again in the request body. This differs from OpenAI Chat Completions, where model is sent in the request body.

    Equivalent Base URL paths

    ScenarioBase URL
    Gate.AI explicit Gemini protocol (recommended)https://api.gate.ai/gemini/v1beta
    Google AI Studio SDK direct access (without /gemini prefix)https://api.gate.ai/v1beta
    Vertex AI style path (with prefix)https://api.gate.ai/gemini/v1/publishers/google/models/{model}:{action}
    Vertex AI style path (without prefix)https://api.gate.ai/v1/publishers/google/models/{model}:{action}

    Text generation

    POST/models/{model}:generateContent

    Generate a model reply from a Gemini native contents[] request body.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: application/json
    modelpathstringYesGemini model ID, such as gemini-2.5-pro

    Request Body

    NameTypeRequiredDescription
    contentsarrayYesGemini conversation turns in order
    contents[].rolestringNouser or model
    contents[].partsarrayYesContent parts in one turn
    parts[].textstringNoText input
    parts[].inlineDataobjectNoMultimodal input with mimeType and base64 data
    toolsarrayNoTool declarations in Gemini functionDeclarations format
    toolConfigobjectNoTool calling policy
    generationConfigobjectNoGeneration settings such as temperature and maxOutputTokens
    systemInstructionobjectNoSystem instruction

    Example

    export GATEAI_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"
    
    curl https://api.gate.ai/gemini/v1beta/models/gemini-2.5-pro:generateContent \
      -H "Authorization: Bearer $GATEAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [
          {
            "role": "user",
            "parts": [
              {"text": "Introduce Gate.AI in one sentence"}
            ]
          }
        ]
      }'

    Response Fields

    NameTypeDescription
    candidatesarrayModel candidate replies
    candidates[].indexintegerCandidate index, starting at 0
    candidates[].content.rolestringAlways model
    candidates[].content.parts[].textstringText reply content
    candidates[].content.parts[].thoughtbooleanWhether the part is model reasoning content
    candidates[].content.parts[].thoughtSignaturestringThought signature for multi-turn reasoning context
    candidates[].content.parts[].functionCallobjectTool call request
    candidates[].finishReasonstringFinish reason, such as STOP
    usageMetadataobjectUsage and billing metadata
    usageMetadata.promptTokenCountintegerInput token count
    usageMetadata.candidatesTokenCountintegerOutput token count
    usageMetadata.totalTokenCountintegerTotal token count
    usageMetadata.coststringRequest cost in USD

    Response Example

    {
      "candidates": [
        {
          "index": 0,
          "content": {
            "role": "model",
            "parts": [
              {
                "text": "Gate.AI is a unified AI model routing platform."
              }
            ]
          },
          "finishReason": "STOP"
        }
      ],
      "usageMetadata": {
        "promptTokenCount": 13,
        "candidatesTokenCount": 37,
        "totalTokenCount": 50,
        "cost": "0.0000964"
      }
    }

    Streaming generation

    POST/models/{model}:streamGenerateContent?alt=sse

    Stream Gemini response chunks. The final chunk usually includes usageMetadata. Read candidates[].content.parts[].text according to the Gemini streaming protocol.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesGate.AI API Key. Format: Bearer <API_KEY>
    Content-TypeheaderstringYesRequest body format: application/json
    modelpathstringYesGemini model ID, such as gemini-2.5-pro

    Request Body

    NameTypeRequiredDescription
    contentsarrayYesGemini conversation turns in order
    contents[].rolestringNouser or model
    contents[].partsarrayYesContent parts in one turn
    parts[].textstringNoText input
    parts[].inlineDataobjectNoMultimodal input with mimeType and base64 data
    toolsarrayNoTool declarations in Gemini functionDeclarations format
    toolConfigobjectNoTool calling policy
    generationConfigobjectNoGeneration settings such as temperature and maxOutputTokens
    systemInstructionobjectNoSystem instruction

    Example

    curl -N "https://api.gate.ai/gemini/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse" \
      -H "Authorization: Bearer $GATEAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "contents": [
          {
            "role": "user",
            "parts": [
              {"text": "List three scenarios where model routing is useful"}
            ]
          }
        ]
      }'

    Multimodal input

    Put images, audio, video, PDF, and other content in the same parts[]. Gate.AI Gemini entry recommends camelCase fields: inlineData.mimeType.

    TypemimeType examples
    Imageimage/png, image/jpeg
    Audioaudio/mp3, audio/wav
    Videovideo/mp4
    PDFapplication/pdf

    Image input example

    IMAGE_B64="$(base64 -i ./image.png | tr -d '\n')"
    
    curl https://api.gate.ai/gemini/v1beta/models/gemini-2.5-pro:generateContent \
      -H "Authorization: Bearer $GATEAI_API_KEY" \
      -H "Content-Type: application/json" \
      -d "{
        \"contents\": [
          {
            \"role\": \"user\",
            \"parts\": [
              {\"text\": \"Describe this image\"},
              {
                \"inlineData\": {
                  \"mimeType\": \"image/png\",
                  \"data\": \"${IMAGE_B64}\"
                }
              }
            ]
          }
        ]
      }"

    Tool calling

    Gemini tools use tools[].functionDeclarations[]. Put the tool policy in toolConfig.functionCallingConfig.

    {
      "contents": [
        {
          "role": "user",
          "parts": [
            {"text": "What should I wear in Beijing today?"}
          ]
        }
      ],
      "tools": [
        {
          "functionDeclarations": [
            {
              "name": "get_weather",
              "description": "Query city weather",
              "parameters": {
                "type": "object",
                "properties": {
                  "city": {
                    "type": "string",
                    "description": "City name"
                  }
                },
                "required": ["city"]
              }
            }
          ]
        }
      ],
      "toolConfig": {
        "functionCallingConfig": {
          "mode": "AUTO"
        }
      }
    }

    When the model triggers a tool, it returns functionCall in candidates[].content.parts[].

    FAQ

    SymptomCauseSuggested fix
    404Missing /gemini/v1beta in the path or wrong model IDUse https://api.gate.ai/gemini/v1beta/models/{model}:generateContent
    Multimodal content not readWrong inlineData field names, MIME type, or base64Use inlineData.mimeType/data and ensure base64 has no line breaks
    Tool not triggeredSchema exceeds Gemini JSON Schema subsetStart with basic fields such as type, properties, required, and description

    Status codes

    StatusMeaningDescription
    200OKRequest succeeded
    400Bad RequestInvalid request body or JSON, or missing required contents / parts
    401UnauthorizedInvalid or missing API Key
    402Payment RequiredInsufficient balance
    404Not FoundInvalid API path, unknown model, or model does not support this protocol
    413Payload Too LargeMultimodal request body too large
    429Too Many RequestsToo many requests. Reduce call frequency.
    500Internal Server ErrorInternal server error
    502Bad GatewayUpstream Gemini service failed

    Difference from OpenAI-compatible access

    If your app already uses OpenAI Chat Completions, you can keep calling Gemini models via https://api.gate.ai/openai/v1/chat/completions. If your app already uses Gemini native contents[] / parts[] format, use the /gemini/v1beta/models/... endpoints on this page for lower migration cost.

    Model List and Pricing API Reference

    Use the Gate.AI model list endpoint to retrieve every available model, its core metadata, and list pricing. It is suited to model selection, comparison tools, and programmatic agent workflows. Each request returns the complete list without pagination.

    FieldValue
    Base URLhttps://gate.ai
    AuthNo authentication required
    FormatGate.AI REST JSON

    List Models

    GET/api/v1/models

    Returns every model currently available on the platform (150+), including display names, providers, input and output modalities, context lengths, and complete list pricing.

    Request Parameters

    NameInTypeRequiredDescription
    langquerystringNoResponse text language: en (default), zh (Simplified Chinese), or zh-tw (Traditional Chinese). This affects description and tags[].name. Values are case-sensitive; invalid values fall back to English.
    context_lengthquerystringNoFilter by context length. Supports comma-separated values, for example 128000,64000. Pass 0, an empty string, or omit the parameter for no limit.
    input_modalityquerystringNoFilter by input modality. Supported values include text, image, and video. Multiple values can be comma-separated, for example text,image.
    keywordquerystringNoFuzzy-search model names against model or base_info.name. Matching is case-insensitive.
    max_input_pricequerynumberNoMaximum input price. Pass 0 or omit the parameter for no limit.
    max_output_pricequerynumberNoMaximum output price. Pass 0 or omit the parameter for no limit.
    min_input_pricequerynumberNoMinimum input price. Defaults to 0 when omitted and uses an open lower bound, excluding models priced at 0.
    min_output_pricequerynumberNoMinimum output price. Defaults to 0 when omitted and uses an open lower bound, excluding models priced at 0.
    output_modalityquerystringNoFilter by output modality. Supported values include text, image, and video. Multiple values can be comma-separated, for example text,image.
    provider_namequerystringNoFilter by the provider name visible to users. Matching ignores case and surrounding whitespace.

    Example

    curl "https://gate.ai/api/v1/models?lang=zh-tw"

    Response Fields

    NameTypeDescription
    codeintegerBusiness status code. Success is always 200.
    messagestringStatus description. Success is success.
    data.dataarrayModel array. Each element is a model object.
    timestampintegerServer timestamp in milliseconds.
    data.data[].modelstringModel ID to pass as the model parameter to generation endpoints.
    data.data[].namestringDisplay name.
    data.data[].provider_namestringModel provider name, such as OpenAI, Anthropic, or ByteDance.
    data.data[].typestringSupported endpoint forms, separated by | when multiple apply: completions, responses, messages, videos, generations, edits, transcriptions, or speech.
    data.data[].input_pricenumber | nullInput price in USD per million tokens. When pricing_tiers exists, this is the first-tier price. It is null for non-token-billed models.
    data.data[].output_pricenumber | nullOutput price in USD per million tokens, with the same semantics as input_price.
    data.data[].cache_read_pricenumber | nullCache-read price in USD per million tokens.
    data.data[].cache_write_pricenumber | nullCache-write price in USD per million tokens.
    data.data[].context_lengthintegerContext length in tokens. Models for which this does not apply return 0.
    data.data[].descriptionstringModel description localized by the lang parameter.
    data.data[].tagsarrayCapability tags containing key (stable English identifier), name (localized by lang), and category.
    data.data[].input_modalitiesarrayInput modalities: text, image, video, or audio. This is platform-maintained reference data and may lag individual upstream model updates.
    data.data[].output_modalitiesarrayOutput modalities, using the same value set as input_modalities.
    data.data[].pricing_tiersobjectPresent only for tier-priced models. input, output, cache_read, and cache_write contain tier arrays with an upper bound and the corresponding price.
    data.data[].video_capabilitiesobjectPresent only for video models: durations (seconds), resolutions, and aspect_ratios.
    data.data[].video_pricingobjectPricing details present only for video models.
    video_pricing.currencystringCurrency. Currently USD.
    video_pricing.billing_modestringper_second_resolution (output seconds × resolution tier) or per_film (per generated video).
    video_pricing.unitstringBilling unit: second or film.
    video_pricing.tiersarrayPricing tiers. Per-second entries contain resolution + price; per-film entries contain resolution + duration + price. Prices are strings.
    data.data[].image_pricingobjectPricing details present only for image models.
    image_pricing.currencystringCurrency. Currently USD.
    image_pricing.billing_modestringper_image or token.
    image_pricing.unitstringBilling unit: image or 1M.
    image_pricing.per_imagestringPrice per image for per-image billing.
    image_pricing.text_input / image_inputobjectPresent for token billing. Each object contains input, output, and cache_read prices in USD per million tokens as strings.
    data.data[].tts_stt_pricingobjectPricing details present only for speech models.
    tts_stt_pricing.billing_modestringtoken or audio_duration.
    tts_stt_pricing.input_tokens / output_tokens / cache_read_tokens / cache_write_tokensstringPresent for token billing, in USD per million tokens.
    tts_stt_pricing.input_per_minutestringPresent for duration billing. Input-audio price per minute in USD.
    data.data[].model_publish_timestring (ISO 8601)Model publication time.

    Response Example

    {
      "code": 200,
      "message": "success",
      "data": {
        "data": [
          {
            "id": 224,
            "model": "qwen3-vl-plus",
            "name": "Qwen3 VL Plus",
            "icon": "https://gimg2.staticimgs.com/image/qwen_20260402_161657_e06ffb27e1219c85184d939bce7cd1bd.webp",
            "provider_type": "qwen",
            "provider_name": "Qwen",
            "type": "completions",
            "input_price": 0.144,
            "output_price": 1.434,
            "cache_read_price": 0.029,
            "cache_write_price": 0.539,
            "price_type": 0,
            "context_length": 262144,
            "description": "Qwen3-VL 系列的 Plus 主力视觉语言模型,支持图像、视频与文本联合输入,擅长文档图表解析、视频理解、空间定位与智能体工具调用,适合多模态问答与视觉自动化场景。",
            "overview": "",
            "tags": [
              {
                "id": 3,
                "key": "vision",
                "name": "视觉",
                "category": "general"
              },
              {
                "id": 28,
                "key": "ui-understanding",
                "name": "界面理解",
                "category": "general"
              },
              {
                "id": 30,
                "key": "document-ocr",
                "name": "文档识别",
                "category": "general"
              },
              {
                "id": 31,
                "key": "multimodal-understanding",
                "name": "多模态理解",
                "category": "general"
              }
            ],
            "input_modalities": [
              "text",
              "image",
              "video"
            ],
            "output_modalities": [
              "text"
            ],
            "playground_enabled": true,
            "model_publish_time": "2025-09-23T00:00:00Z",
            "create_time": "2026-06-05T14:18:56Z",
            "update_time": "2026-07-06T01:57:19Z",
            "pricing_tiers": {
              "input": [
                {
                  "upper": 32000,
                  "input_price": "0.144"
                },
                {
                  "upper": 128000,
                  "input_price": "0.216"
                },
                {
                  "upper": null,
                  "input_price": "0.431"
                }
              ],
              "output": [
                {
                  "upper": 32000,
                  "output_price": "1.434"
                },
                {
                  "upper": 128000,
                  "output_price": "2.151"
                },
                {
                  "upper": null,
                  "output_price": "4.301"
                }
              ],
              "cache_read": [
                {
                  "upper": 32000,
                  "cache_read_price": "0.029"
                },
                {
                  "upper": 128000,
                  "cache_read_price": "0.044"
                },
                {
                  "upper": null,
                  "cache_read_price": "0.087"
                }
              ],
              "cache_write": [
                {
                  "upper": null,
                  "cache_write_price": "0.539"
                }
              ]
            }
          }
        ]
      },
      "timestamp": "1784201129"
    }

    Response

    StatusMeaningDescriptionSchema
    200OKSuccess. Returns the complete model list.ModelsResponse
    500Internal Server ErrorInternal server error.ErrorResponse
    Compatibility notice: Response fields not listed on this page are internal platform fields and may change at any time; do not depend on them. Fields documented here may be added to in a backward-compatible way but will not receive breaking changes.

    Check Balance

    Query the balance status for the user that owns the current API Key.

    FieldValue
    Base URLhttps://api.gate.ai
    AuthAuthorization: Bearer <API_KEY>
    FormatGate.AI REST JSON

    Get Credits Balance

    GET/api/v1/credits/balance

    Query the balance status for the user that owns the current API Key.

    Request Parameters

    NameInTypeRequiredDescription
    AuthorizationheaderstringYesAPI Key authentication. Format: Bearer <API_KEY>

    Response Fields

    NameTypeDescription
    codeintegerBusiness status code. Success is always 200.
    dataobjectBalance data.
    data.statusintegerBalance status: 1 tradable, 2 insufficient balance, 4 overdue debt.
    data.messagestringStatus description.
    data.asset_typestringAsset ownership type: user_asset for personal assets, organization_asset for organization assets.
    data.recharge_balancestringRecharge balance.
    data.debt_amountstringDebt amount. Empty string or a zero-value string when there is no debt.

    Response Example

    {
      "code": 200,
      "data": {
        "status": 1,
        "message": "可以交易",
        "asset_type": "user_asset",
        "recharge_balance": "12.34000000",
        "debt_amount": ""
      }
    }

    Response

    StatusMeaningDescriptionSchema
    200OKQuery succeeded. Returns code and data.CreditsBalanceResponse
    401UnauthorizedAPI Key is missing, invalid, expired, revoked, disabled, or inactive.ErrorResponse
    403ForbiddenThe member that owns the current API Key does not have permission to view the balance.ErrorResponse
    429Too Many RequestsRate limit reached.ErrorResponse
    500Internal Server ErrorGateway internal error, such as API Key lookup failure or response serialization failure.ErrorResponse
    502Bad GatewayBalance upstream service is unavailable, returned a non-success status, response parsing failed, or data is empty.ErrorResponse

    Error Response Example

    {
      "error": {
        "type": "authentication_error",
        "code": "7022002001",
        "message": "invalid api key"
      }
    }

    Troubleshooting

    Authentication Errors

    Error messageHTTP statusCauseSolution
    invalid api key401The API Key is invalid, expired, revoked, or disabledGo to Console → API Keys and confirm the key status is "active". If it has expired, generate a new one

    Routing and Model Errors

    Error messageHTTP statusCauseSolution
    no model config found for: {model}404The requested model ID does not existOpen the model list and confirm the model ID is spelled correctly
    model field is required400The request body is missing the model fieldAdd "model": "model name" to the request JSON
    invalid or empty requested model400The requested model name is empty or invalidOpen the model list and confirm you are using the correct model ID format
    unknown api path404The API path is incorrectConfirm the Base URL is https://api.gate.ai/openai/v1 or https://api.gate.ai/anthropic

    Request Parameter Errors

    Error messageHTTP statusCauseSolution
    invalid JSON body400The request body is not valid JSONCheck that the request body is valid JSON
    failed to read request body400The request body could not be readConfirm the body is not corrupted and Content-Type is set to application/json
    failed to rewrite request body500Failed to rewrite the request body inside the gatewayRetry. If it keeps happening, contact technical support
    images are not supported by this model400The target model does not support image inputSwitch to a multimodal model that supports images, such as gpt-4o
    audio is not supported by this model400The target model does not support audio inputSwitch to a model that supports audio input
    unsupported parameter: max_tokens400Some models do not support the max_tokens parameterUse max_completion_tokens instead

    Quota and Rate Limit Errors

    Error messageHTTP statusCauseSolution
    api key budget quota exceeded429The API Key budget has been exhaustedGo to Console → API Keys → Budget settings, increase the budget, or wait for the quota to reset
    guardrail budget limit exceeded429The guardrail budget limit has been exceededCheck the budget limit in guardrail settings, then increase the limit or reduce usage frequency
    organization guardrail budget limit exceeded429The organization-level guardrail budget has been exceededContact an organization admin to adjust the organization-level budget limit
    model not allowed by guardrail policy403The model is not allowed by the guardrail policyGo to Console → Guardrails and add the target model to the allowlist
    The free model usage has reached its daily global limit today.429The global daily limit for the free model has been reachedWait for the next daily reset, or upgrade to a paid plan for unrestricted models
    The free model usage has reached its daily limit today.429Your personal daily limit for the free model has been reachedWait for the next daily reset, or upgrade to a paid plan
    Guest daily spending limit exceeded. Please try again tomorrow or upgrade to a paid plan.429The guest daily spending limit has been exceededRegister an account and upgrade to a paid plan, or wait for the next daily reset

    Billing and Balance Errors

    Error messageHTTP statusCauseSolution
    Pending payment {amount} USD — Please top up...402The account balance is insufficient and has an outstanding paymentTop up with Gate Pay
    Insufficient balance and account in debt402The balance is insufficient and the account is in debtTop up with Gate Pay
    billing model info not found for model "{model}"400Billing information for the model does not existConfirm the model ID is correct. If it is a new model, contact technical support to configure billing rules
    billing model info is ambiguous for model "{model}"400Billing information is ambiguous because multiple records matchContact technical support to check the model billing configuration
    billing configuration error500Billing rules are misconfigured on the serverContact technical support to fix the billing configuration

    Upstream Service Errors

    Error messageHTTP statusCauseSolution
    bad gateway502The gateway failed to communicate with the upstream serviceRetry. If it keeps happening, check the service status page or contact technical support
    upstream service unavailable502The upstream AI Provider is unavailableRetry later, or switch to another available model
    upstream service error502The upstream AI Provider returned an errorCheck whether the request parameters match the target model requirements. If it keeps happening, contact technical support
    request timeout504The upstream request timed outReduce the input length or increase the timeout, then retry
    no provider handler configured for protocol502No protocol handler is configured in the gatewayContact technical support to check the gateway configuration

    Server Internal Errors

    Error messageHTTP statusCauseSolution
    internal server error500Internal gateway errorRetry. If it keeps happening, contact technical support with the Request ID
    failed to record request log500Failed to record the request logThis does not affect the request result and can be ignored. Contact technical support if it happens frequently
    failed to list models500Failed to query the model listRetry. If it keeps happening, contact technical support

    Common Quick Checks

    Incorrect Base URL

    # ❌ Incorrect
    https://api.gate.ai/v1/chat/completions
    
    # ✅ Correct
    https://api.gate.ai/openai/v1/chat/completions  # OpenAI protocol
    https://api.gate.ai/anthropic/v1/messages  # Anthropic protocol

    Incompatible max_tokens Parameter

    // ❌ Some models do not support this
    { "model": "gpt-4o", "max_tokens": 100 }
    
    // ✅ Use max_completion_tokens
    { "model": "openai/gpt-5.5", "max_completion_tokens": 100 }

    API Key Format

    # ✅ Correct request headers
    Authorization: Bearer sk-xxxxxxxxxxxxxxxxxxxx # OpenAI protocol
    X-api-key: sk-xxxxxxxxxxxxxxxxxxxx # Anthropic protocol