AIRouter 文档

3 分钟完成接入,之后只需要管你的子 key 与预算。

快速开始

  1. 用 GitHub 登录
  2. 控制台 · Keys 上传你的 OpenRouter Provisioning Key(推荐只给最小权限)。
  3. 控制台 · 子 key 点「新建子 key」,设置月 / 日预算、模型白名单、IP 白名单,生成以 sk-cn- 开头的子 key。
  4. 把子 key 当作 OpenRouter Key 使用,API Base 换成 https://api.airouter.mpoll.top/v1

为什么要用子 key

  • 花超即拒:每个子 key 独立月 / 日预算。
  • 模型白名单:防止团队误用贵模型。
  • IP 白名单:子 key 泄漏也跑不出机房。
  • 一键撤销:父 key 安然无恙。

API 用法(OpenAI 兼容)

完全兼容 OpenAI / OpenRouter 的 /v1/chat/completions

cURL

curl https://api.airouter.mpoll.top/v1/chat/completions \
  -H "Authorization: Bearer sk-cn-你的子key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4o-mini",
    "messages": [{"role":"user","content":"你好"}]
  }'

Python (openai SDK)

from openai import OpenAI
client = OpenAI(
    api_key="sk-cn-你的子key",
    base_url="https://api.airouter.mpoll.top/v1",
)
resp = client.chat.completions.create(
    model="openai/gpt-4o-mini",
    messages=[{"role":"user","content":"你好"}],
)
print(resp.choices[0].message.content)

Node.js (openai SDK)

import OpenAI from "openai";
const client = new OpenAI({
  apiKey: "sk-cn-你的子key",
  baseURL: "https://api.airouter.mpoll.top/v1",
});
const r = await client.chat.completions.create({
  model: "openai/gpt-4o-mini",
  messages: [{ role: "user", content: "你好" }],
});
console.log(r.choices[0].message.content);

流式(SSE)

curl -N https://api.airouter.mpoll.top/v1/chat/completions \
  -H "Authorization: Bearer sk-cn-xxx" \
  -d '{"model":"openai/gpt-4o-mini","stream":true,"messages":[...]}'

错误码

状态码含义
401子 key 不存在 / 已禁用 / 已过期
402预算耗尽(月 / 日)
403IP 不在白名单 / 模型不在白名单
429达到速率限制(默认 IP 2 rps,子 key 1 rps)
502上游 OpenRouter 故障

限流

免费档:IP 级 2 rps / 120 突发子 key 级 1 rps / 60 突发。Pro / Team 档位可后台调整。

模型列表

所有 OpenRouter 支持的模型都可用。价格同步自官方,以 GET /v1/models 返回为准。

FAQ

会加价吗?

不会。Token 消耗按你 OpenRouter 账户的官方账单走。

Prompt 会被保存吗?

不会。只记录调用元数据(时间、模型、Token 数、费用、状态)。

可以自己部署吗?

Enterprise 档支持私有部署,联系我们