錯誤處理
錯誤格式對齊 OpenAI:單一 `error` 物件包含 `message` / `type` / `code` 三個欄位。常見 code: `invalid_api_key` (401)、`insufficient_balance` (402)、`rate_limit_exceeded` (429)、`tenant_monthly_quota_exceeded` (429)、`upstream_error` (502)。上游 5xx 我們會透明重試;只有所有重試都失敗你才會看到最終錯誤。
json
{
"error": {
"message": "Account balance depleted. Please top up to continue.",
"type": "insufficient_balance",
"code": "account_suspended"
}
}速率限制
每 key 預設 60 RPM。超限回傳 429,附 `X-RateLimit-Remaining` 和 `X-RateLimit-Reset` 頭。企業方案可放寬上限-聯絡我們客製化。
回應頭
每次回應都附帶實用元資料頭:
| X-Trace-ID | unique request ID, include it in support tickets |
| X-Usage-Input-Tokens | input tokens counted for billing |
| X-Usage-Output-Tokens | output tokens counted for billing |
| X-RateLimit-Remaining | remaining requests in current window |
| X-RateLimit-Reset | seconds until window resets |
價格
所有內部模型統一平價:輸入 $3.00 / 百萬 token,輸出 $12.00 / 百萬 token。快取命中(精確 + 語意)以正常價 25% 計費。重試和對沖路徑的成本由我們內部吸收——你只為最終看到的答案付費。