خطاها
همهٔ خطاها یک ساختار واحد دارند: {"error":{"code":"...","message":"...","status":...}}. فیلد code ماشینخوان و پایدار است (مثل INSUFFICIENT_CREDITS)، message برای انسان است و ممکن است تغییر کند، و status همان کد HTTP است. روی code شرط بنویسید، نه روی متن پیام.
کدام خطاها را دوباره تلاش کنیم؟
429. با توجه به هدرRetry-Afterصبر کنید و دوباره بفرستید.500/502/503/504. با backoff دوباره تلاش کنید؛ اگرIdempotency-Keyفرستاده باشید، تکرار امن است.400/401/402/409. تکرار بیفایده است؛ اول مشکل درخواست، کلید یا اعتبار را رفع کنید.499یعنی کلاینت خودتان اتصال را قطع کرده؛ هزینهای ثبت نشده است.
فهرست خطاها
| کد وضعیت | code | توضیح |
|---|---|---|
| 400 | BAD_REQUEST | The request body or query parameters are invalid. Check the
|
| 400 | INVALID_TOOLS | Returned when the
The error message names the offender and includes a migration hint. The hold has NOT been placed (no charge). |
| 400 | UNSUPPORTED_IMAGE_FORMAT | The image bytes could not be decoded (HEIC, AVIF, partial bytes,
non-image content). The classifier requires JPEG, PNG, WebP, or
GIF input. Re-encode the image and resend with a fresh
|
| 401 | UNAUTHORIZED | Authentication failed. Either the |
| 404 | NOT_FOUND | The requested resource was not found. Either the ID is wrong or it belongs to a different account. |
| 409 | CONFLICT | Idempotency key conflict: you sent the same |
| 429 | RATE_LIMITED | Too many requests. Back off and retry after a short delay.
Check the |
| 499 | CLIENT_CLOSED | Your HTTP client cancelled the request before the gateway finished. No charge: the hold has been released. The most common cause is a 30 s default client timeout against a model whose p95 latency is 45-60 s; bump your client timeout to 120 s. Retries with the same |
| 500 | INTERNAL_ERROR | Unexpected server error. Please retry with exponential backoff. If the issue persists, contact your admin. |
| 502 | UPSTREAM_ERROR | The upstream AI provider is temporarily
unavailable. Retry with exponential backoff (1s, 2s, 4s) using the
same |
| 504 | UPSTREAM_TIMEOUT | The gateway's 120 s upstream deadline elapsed before the upstream
provider produced a response. Retry with the same
|
سوالات متداول
- خطای 402 INSUFFICIENT_CREDITS یعنی چه؟
اعتبار حساب برای بلوکهٔ این درخواست کافی نیست. درخواست اصلاً به مدل نمیرسد و هزینهای ثبت نمیشود؛ حساب را شارژ کنید و دوباره بفرستید.
- چرا 499 میگیرم؟
کلاینت HTTP شما پیش از پایان پاسخ، اتصال را بسته (معمولاً تایماوت کوتاه). تایماوت را بالا ببرید یا استریم را روشن کنید؛ مبلغ بلوکهشده آزاد شده است.