GateRouter Documentation

    統一的 AI 模型路由平台。一個 API Key,25+ 模型,智慧自動路由。


    快速開始

    1. 取得 API Key

    1. 前往 gaterouter.ai,使用 Gate 帳號登入
    2. 進入 Dashboard → 產生 API Key

    2. 啟用自動路由(選用)

    智慧路由(auto 模型)預設未開啟。開啟方式:

    Dashboard → 路由設定 → 開啟 Auto Routing

    啟用後,GateRouter 會自動為每個請求選擇最佳模型。若你偏好自行選擇模型,可略過此步驟,直接指定模型(如 anthropic/claude-sonnet-4.6)。


    標準接入

    相容任何 OpenAI 相容客戶端 — Python、Node.js、Golang、curl、LangChain、LlamaIndex 等。

    只需更換 base URL 和 API Key,其他程式碼保持不變。

    from openai import OpenAI
    
    client = OpenAI(
        api_key="GATEROUTER_API_KEY",  # get GATEROUTER_API_KEY from gaterouter.ai (API Key)
        base_url="https://api.gaterouter.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)

    回應範例:

    {
        "id": "243c850e-214c-431e-977f-ebaf4aa95f56",
        "choices": [
            {
                "index": 0,
                "message": {
                    "role": "assistant",
                    "content": "你好!很高兴见到你,有什么我可以帮你的吗?😊"
                },
                "finish_reason": "stop"
            }
        ],
        "created": 1773408946,
        "model": "deepseek.v3-v1:0",
        "object": "chat.completion",
        "usage": {
            "prompt_tokens": 5,
            "completion_tokens": 15,
            "total_tokens": 20
        }
    }

    OpenClaw 接入

    如果你使用 OpenClaw,GateRouter 可作為 skill 整合。

    快速設定

    bash {baseDir}/scripts/setup.sh <YOUR_API_KEY> <OPENCLAW_ROOT>

    腳本將自動完成:

    1. 測試 API 連通性(包含自動路由偵測)
    2. 將 API Key 寫入 .env
    3. 將 GateRouter provider 新增至 models.json
    4. 更新 openclaw.json,將 gaterouter/auto 設為主模型

    手動設定

    1. 在 OpenClaw 根目錄的 .env 中新增:

    GATEROUTER_API_KEY="sk-or-v1-xxxxxxxxxxxxxxxx"

    2. 更新 openclaw.json:

    {
      "agents": {
        "defaults": {
          "model": {
            "primary": "gaterouter/auto",
            "fallbacks": [
              "gaterouter/anthropic/claude-sonnet-4.6",
              "openrouter/anthropic/claude-sonnet-4.6"
            ]
          }
        }
      },
      "auth": {
        "profiles": {
          "gaterouter:default": {
            "provider": "gaterouter",
            "mode": "api_key"
          }
        }
      }
    }

    3. 重新啟動 OpenClaw agent。


    API 參考

    欄位
    Base URLhttps://api.gaterouter.ai/openai/v1
    認證Authorization: Bearer <API_KEY>
    格式OpenAI 相容
    計費按量計費,2.5% 加價

    注意: API 路徑是 /openai/v1(不是 /v1)。

    端點

    方法路徑描述
    POST/v1/chat/completions聊天補全(支援串流)
    GET/v1/models取得可用模型列表

    可用模型

    模型 ID描述用途
    auto智慧路由,自動選擇最佳模型日常使用(推薦)
    anthropic/claude-opus-4.6Anthropic 最強模型複雜推理
    anthropic/claude-sonnet-4.6Anthropic 均衡通用
    anthropic/claude-sonnet-4.5Anthropic 上一代通用
    anthropic/claude-haiku-4.5Anthropic 快速簡單任務
    openai/gpt-5OpenAI GPT-5通用
    openai/gpt-5.2OpenAI 最新推理任務
    openai/gpt-4.1OpenAI 穩定通用
    google/gemini-2.5-proGoogle 最強模型長上下文
    deepseek/deepseek-v3.2DeepSeek 最新高性價比

    模型 ID 格式:provider/model-name。版本號使用 .(如 4.6),而非 -。


    故障排除

    錯誤原因解決方案
    auto routing is not enabled未開啟自動路由在 Dashboard 中開啟
    provider routing is not configured模型 ID 格式錯誤使用 provider/model-name 格式,版本號用 .
    404 page not foundAPI 路徑錯誤確認 base URL 以 /openai/v1 結尾
    unsupported parameter: max_tokens部分模型不支援該參數改用 max_completion_tokens