BangAI API 文档
契约 v1.1(v1.0 向后兼容)· 基路径 /v1 · 鉴权 Authorization: Bearer <API_KEY>(未配置 Key 时鉴权禁用)
端点总览
| 方法 | 路径 | 说明 |
GET/v1/health | 服务健康(开放) |
POST/v1/chat/completions | 轻量直通(primary_reasoner) |
POST/v1/reason | 深推理全 D1(60-120s) |
POST/v1/scenes | 场景注册(v1.1) |
GET/v1/scenes | 场景列表(v1.1) |
DELETE/v1/scenes/{id} | 注销场景(v1.1) |
POST/v1/auth/login | 登录(ops 用户体系,P1) |
POST/v1/proxy/chat | 对话(前端代理,无 Key) |
POST/v1/proxy/reason | 深推理(前端代理) |
POST/v1/proxy/reason/stream | 深推理 SSE 流(processing→result→done) |
POST /v1/reason(深推理)
curl -X POST https://www.bbangai.cn/v1/reason \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $BANGAI_API_KEY" \
-d '{"scene_id":"general","task_type":"general","input":"1+1等于几?"}'
# 响应:final_answer + claims(trust_label) + audit_hash + metering
POST /v1/chat/completions(OpenAI 兼容)
curl -X POST https://www.bbangai.cn/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $BANGAI_API_KEY" \
-d '{"messages":[{"role":"user","content":"你好"}]}'
错误码(统一格式 {"error":{"code","message"}})
| HTTP | code | 说明 |
| 400 | validation_error / http_error | 请求非法 |
| 401 | unauthorized | 缺/错 Key |
| 402 | quota_exceeded | 配额不足(计量) |
| 404 | not_found | 资源不存在 |
| 409 | scene_already_exists | 场景重复注册 |
| 429 | rate_limited | 限流 |
| 500 | internal_error | 服务内部错误 |
可信标注(claims.trust_label)
| 标签 | 语义(分级提示,非统计概率) |
RELIABLE | 有证据支持或评审一致 |
PLAUSIBLE | 逻辑自洽但缺外部证据 |
UNVERIFIED | 无证据可验证 |
CONTRADICTED | 与证据矛盾 |
SYCOPHANTIC | 立场漂移/谄媚风险 |