שגיאות
כיצד לפרש שגיאות בקשה ומשימות תמונה שנכשלו.
איך קוראים שגיאה
סטטוס ה-HTTP מתאר את הבקשה ל-API, ואילו error.code מתאר את סיבת הכשל. אלה שני שדות נפרדים: HTTP 200 אינו קוד שגיאה עסקי.
- שליחה שנדחתה מחזירה סטטוס HTTP של שגיאה יחד עם אובייקט
error. - תשאול משימה שהצליח מחזיר HTTP 200. קרא את
statusכדי לדעת אם היצירה במצבprocessing,completedאוfailed. - במשימה שנכשלה, הסתעף לפי
error.codeולא לפי הטקסט שב-message. לסיבות כשל שונות יש קודים שונים; אותה סיבה משתמשת באותו קוד בכל המודלים. 60002הוא ערך ברירת המחדל כשלא ניתן לקבוע סיבה ציבורית ספציפית יותר. התייחס לקודים עתידיים שאינך מזהה ככשל כללי.
קודי השגיאה וההודעות בטבלה שלהלן מוחזרים מה-API כלשונם ולכן נשארים באנגלית: הם זהים תו בתו ל-error.message שהלקוח שלך מקבל בפועל.
Request errors
These HTTP statuses describe a rejected or unconfirmed submission, or a failed task query. A submission timeout does not prove that no task was created.
Error code (error.code) | HTTP status | Meaning | Next step |
|---|---|---|---|
10001 | 401 | The API key is missing or invalid. | Check the Authorization header and API key. |
10002 | 403 | You do not have permission to make this request. | Check access permissions. |
20001 | 400, 413, 422 | The request was rejected. Check the parameters against the API documentation. | Correct the request parameters before retrying. |
20002 | 400 | The requested model is not available. | Select a model listed in the model catalog. |
30001 | 402 | Not enough credits to run this request. | Add credits before submitting. |
30002 | 429 | Too many requests. Please wait and try again. | Wait and retry with backoff. Do not repeat accepted submissions. |
50001 | 404 | Task not found. | Check the task ID and use the owning account’s key. |
50002 | 503 | Submission could not be confirmed. Check your tasks before submitting again. | Check task history before submitting again; the request may have been accepted. |
90001 | 503 | The service is temporarily unavailable. | Back off; retain any task ID already received. |
Task failures
A successful task query returns HTTP 200 even when generation failed. Check status: "failed" and error.code in the response. These codes describe the task outcome, not the HTTP request. Failed tasks are not charged.
Error code (error.code) | Meaning | Next step |
|---|---|---|
20001 | The request was rejected. Check the parameters against the API documentation. | Correct the request parameters before retrying. |
50003 | The task did not complete within the allowed time. Please try again. | The task is not charged. You may submit a new task. |
60001 | The request was rejected by the content policy. Please revise the prompt or input images. | Revise the prompt or media input. |
60002 | Generation could not be completed. Please try again. | The task is not charged. You may submit a new task. |
60003 | No output was generated. Please revise the prompt or try again. | Revise the input or submit a new task. |
60004 | The generated output could not be delivered. Please try again. | The task is not charged. Try again later. |
90001 | The service is temporarily unavailable. | Back off; retain any task ID already received. |
{
"id": "task_...",
"status": "failed",
"error": {
"code": 60002,
"message": "Generation could not be completed. Please try again."
}
}אם השליחה עצמה חורגת מהזמן הקצוב, בדוק את היסטוריית המשימות לפני שליחה חוזרת: ייתכן שהבקשה הראשונה כבר התקבלה.
