AI API Gateway

统一 AI 入口 · 自动路由 / 指定路由 · 用量统计

Worker 地址

https://ai-api-gateway.hb67egcim4.workers.dev

鉴权 Header:X-Gateway-TokenREQUIRE_GATEWAY_TOKEN=false 时可省略)· 归因:X-Caller-Worker

三云接入矩阵

GET /v1/capabilities/v1/models/v1/providers/status 动态渲染,与线上一致。

加载中…

路由模式

options.routing说明
auto / cost_optimal按 config/routes.json 顺序尝试,跳过额度用尽/不健康后端
explicit必须同时指定 options.provider + options.model
free_only仅用免费额度后端(CF m2m100、Azure F0 等)
quality_first优先 Vertex Pro 等高质量模型
vertex_only / azure_only / cf_only锁定单一云厂商

能力一览

capability路径状态
加载中…

自动路由示例

curl -X POST "$WORKER/v1/translate" \
  -H "Content-Type: application/json" \
  -H "X-Caller-Worker: youtube-translate" \
  -d '{
    "input": {
      "segments": [{"start":0,"end":1,"text":"Hello"}],
      "target_lang": "zh"
    },
    "options": { "routing": "cost_optimal" }
  }'

指定路由示例

curl -X POST "$WORKER/v1/vision.ocr" \
  -H "Content-Type: application/json" \
  -d '{
    "input": { "image_base64": "...", "mime": "image/png" },
    "options": {
      "routing": "explicit",
      "provider": "vertex",
      "model": "gemini-3.1-flash-lite-preview"
    }
  }'

今日用量

Cloudflare 额度以 Dashboard GraphQL 官方 Neurons 为准;下方「网关估算」仅作 D1 记账参考。

加载中…

新增 AI 能力

详见仓库文档:

配置三件套:config/models.json · config/routes.json · src/capabilities/

业务 Worker 接入:在 wrangler.toml 添加 [[services]] binding = "AI_GATEWAY" service = "ai-api-gateway",经 Service Binding 调用 /v1/{capability}