文档 · 路由与运营
自动路由 + 回退
传 model="auto" 时,分类器会从意图、输入 Token 数、预期输出长度与是否需要工具几个维度打分, 挑出帕累托前沿上单价最低的模型。回退链显式有序,命中结果写到响应头。
§ 01
auto 别名
- auto
- 默认 — 成本与质量帕累托最优
- auto:cheap
- 最低单价(牺牲一点质量)
- auto:strong
- 不计成本拿质量上限
- auto:cn-only
- 仅国产模型(DeepSeek / Qwen / GLM / Kimi)
- auto:no-anthropic
- 排除 Anthropic 系
§ 02
覆盖回退链与预算
curl https://api.cdgo.ai/v1/chat/completions \
-H "Authorization: Bearer sk-cdgo-..." \
-H "Content-Type: application/json" \
-d '{
"model": "auto",
"messages": [{"role":"user","content":"summarise this PR title"}],
"cdgo": {
"fallback": ["gpt-4o-mini", "deepseek-v3", "qwen3-235b-a22b"],
"max_cost_usd": 0.002,
"require": ["json_mode"]
}
}'§ 03
响应头
- x-cdgo-route
- 实际命中模型
- x-cdgo-fallback
- 0 = 首选命中;>0 = 第 N 次回退
- x-cdgo-upstream
- 上游账户与 region
- x-cdgo-score
- 分类器得分 0–1
- x-cdgo-cache
- hit / miss / bypass
- x-cdgo-request-id
- 追踪 ID,附在工单里
§ 04
请求路径示意
client edge router upstream
────── ────── ────── ────────
POST /v1/chat ──► TLS · 鉴权 ──► classify ───────► primary
model="auto" quota check score 0.42 │
│ │ ▼
│ pick gpt-4o-mini OpenAI us-east
│ │ │
│ │ ◄── 200 OK ──────┘
│ │
│ [ if 5xx / timeout / >max_cost ]
│ │
│ ├──► fallback #1 ─► DeepSeek-V3
│ │ (CN-NM upstream)
│ │
│ └──► fallback #2 ─► Qwen3-235B
│
◄──── stream/JSON ────┘
headers: x-cdgo-route = gpt-4o-mini
x-cdgo-fallback = 0
x-cdgo-score = 0.42
x-cdgo-cache = miss
meter ──► Postgres (CN-NM) 审计 · 用量 · 计费回退顺序对每条 Key 都可以预设;请求体里的 cdgo.fallback 会临时覆盖默认链。计费始终按最终成功的那一次模型计算。 月度估算见 /calculator。