ANY
Error Codes错误码总览
六大错误码体系与重试策略矩阵:429 与 500 可重试,401、402、404、422 不可。
Error Codes六大错误码体系与重试策略矩阵:429 与 500 可重试,401、402、404、422 不可。
全平台统一使用六大错误码:401 unauthorized(认证失败)、402 quota_exceeded(配额耗尽)、404 session_not_found(资源不存在)、422 invalid_event(请求体非法)、429 rate_limited(触发限流)、500 internal_error(服务端错误)。错误响应为统一结构:error.code 为错误名,error.message 为可读说明,error.request_id 用于追踪,error.doc_url 指向对应文档。
重试策略矩阵:429 与 500 为可重试错误——429 按 Retry-After 指数退避,500 以指数退避加重试上限 3 次;401、402、404、422 为不可重试错误——重试必然得到相同结果,须先修复根因(更换或补齐 Key、升档或等待配额重置、核对资源 id、修正请求体)。
所有写操作端点(创建会话、推送事件、结束会话等)的重试必须携带相同的 Idempotency-Key:服务端按 Key 返回首次处理结果,保证重试不产生重复副作用。任何错误连续出现 3 次以上,应携带 request_id 提交工单。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| error.code | string | 是 | 错误名,六大错误码之一:unauthorized|quota_exceeded|session_not_found|invalid_event|rate_limited|internal_error |
| error.message | string | 是 | 人类可读的错误说明,含定位提示,直接可用于日志 |
| error.request_id | string | 是 | 请求追踪 id,工单与对账的必填信息 |
| error.doc_url | string | 否 | 指向对应端点文档或本页的链接,便于排障时跳转 |
| error.detail | string | 否 | 可选的细分原因(如 data_agreement_required),不改变错误码本身 |
curl -X POST https://api.zhenren.com.cn/v1/games/ddz2/sessions \
-H "Authorization: Bearer sk_live_xxxxxxxx" \
-H "Content-Type: application/json" \
-d '{ "robots": 5 }' // ddz2 机器人上限为 1,返回 422 invalid_event{
"error": {
"code": "invalid_event",
"message": "玩法 id 不存在或参数组合非法(如 robots 超过玩法上限)",
"request_id": "req_c4m1f",
"doc_url": "https://zhenren.com.cn/docs/reference/error-codes"
}
}30 天全功能免费试用,5 分钟接入首个AI牌局。开通试用请添加商务微信 kxlin0101 或发送邮件至 skyin.lewis@gmail.com。