開發者

文檔

ad9.io 相容 Anthropic 與 OpenAI 兩種協議。已在用 Claude Code、Codex、官方 SDK 或 curl?通常只要把 base_url 換成 api.ad9.io、帶上你的 ad9 Key 就能跑。

快速開始 認證與端點 模型 錯誤碼 免費檔限制

快速開始

一鍵配置(Claude Code)

在終端執行下面一行,貼上你的 ad9 Key 即可把 Claude Code 指向 ad9.io:

curl -fsSL https://ad9.io/install/claude-code.sh | bash

用 Codex 或其他 OpenAI 相容工具?改用:

curl -fsSL https://ad9.io/install/codex.sh | bash

Windows(PowerShell):

irm https://ad9.io/install/claude-code.ps1 | iex

直接用 curl

curl https://api.ad9.io/api/v1/messages \
  -H "x-api-key: ad9-你的key" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{"model":"claude-haiku-4-5","max_tokens":256,"messages":[{"role":"user","content":"Hello!"}]}'

Python (anthropic SDK)

pip install anthropic
import anthropic
client = anthropic.Anthropic(base_url="https://api.ad9.io/api", api_key="ad9-YOUR_KEY")
msg = client.messages.create(model="claude-haiku-4-5", max_tokens=256,
    messages=[{"role":"user","content":"Hello!"}])
print(msg.content[0].text)

Node.js (@anthropic-ai/sdk)

import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.ad9.io/api", apiKey: "ad9-YOUR_KEY" });
const msg = await client.messages.create({ model: "claude-haiku-4-5", max_tokens: 256,
  messages: [{ role: "user", content: "Hello!" }] });
console.log(msg.content[0].text);

認證與端點

用帳戶頁生成的 ad9 Key 認證。Anthropic 協議用 x-api-key 標頭,OpenAI 協議用 Authorization: Bearer。按你的 SDK 選對應 base_url:

協議 / 工具base_url認證標頭
Anthropic(Claude Code, SDK)https://api.ad9.io/apix-api-key: ad9-…
OpenAI(Codex, SDK)https://api.ad9.io/openai/v1Authorization: Bearer ad9-…
Geminihttps://api.ad9.io/geminix-goog-api-key: ad9-…

查詢額度與用量:GET /api/v1/key(回傳檔位、日額、已用、剩餘)。到 帳戶頁 可複製 Key、看用量、重置。

模型

免費檔開放中低階模型;opus / 旗艦 gpt / fable 等高階模型需付費檔(訂閱、加油包或錢包)。完整用 GET /api/v1/models 查。

可用檔位模型(示例)
免費 + 付費claude-sonnet-5 · claude-haiku-4-5 · gemini-2.5-flash · gpt-5.6-mini · gpt-5.6-nano
僅付費claude-opus-4-8 · claude-fable-5 · gpt-5.6 · 更多旗艦

錯誤碼

錯誤體是標準協議格式。撞到「可升級」的牆(付費模型 / 配額 / 並發)時,錯誤體會多帶一個機器可讀的 ad9_upgrade 欄位,方便你的程式引導升級。

狀態含義怎麼辦
401Key 無效或未激活檢查 Key 是否正確、是否已重置
403免費檔調了付費模型換中低階模型,或升級付費檔
402配額用盡 / 無可用額度等 00:00(UTC+8,新加坡時間)刷新,或充值 / 升級 / 邀請好友
429並發超限依 Retry-After 重試;付費檔並發更高

ad9_upgrade 示例(402):

{
  "error": { "type": "billing_error", "message": "Daily quota exhausted…" },
  "ad9_upgrade": {
    "reason": "quota_exhausted",
    "resets_at": "00:00 UTC+8 (Asia/Singapore)",
    "upgrade_url": "https://ad9.io/pricing"
  }
}

免費檔限制

準備好了?免費獲取 API Key,或看 定價