Understand common API errors and recovery steps.
Error Codes
The API uses standard HTTP status codes and returns structured JSON for most failures.
| Code | Meaning | Resolution |
|---|---|---|
| 400 | Bad Request | Check the request payload and required fields. |
| 401 | Unauthorized | Check the API key and Authorization header. |
| 404 | Not Found | Check the model, image, video, or job ID. |
| 409 | Conflict | Retry the request later. |
| 429 | Rate Limit | Apply backoff before retrying generation jobs. |
| 5xx | Server Error | Retry later or contact support. |
Error response
Error responses may include:
{
"status": "NOK",
"message": "Human-readable error message",
"err": "Internal or validation error detail",
"result": null
}Not every field is guaranteed on every error. Prefer message for user-facing handling and
log err for debugging when it is present.
Basic error handling
const response = await fetch(`${BASE_URL}/models`, {
headers,
})
if (response.status === 401) {
throw new Error('Invalid or missing API key.')
}
if (response.status === 429) {
throw new Error('Rate limit reached. Retry with backoff.')
}
if (!response.ok) {
throw new Error(await response.text())
}response = requests.get(f"{BASE_URL}/models", headers=headers)
if response.status_code == 401:
raise Exception("Invalid or missing API key.")
if response.status_code == 429:
raise Exception("Rate limit reached. Retry with backoff.")
response.raise_for_status()Retry guidance
Retry only requests that are safe for your integration to repeat.
| Status | Retry? | Notes |
|---|---|---|
400 | No | Fix the request payload first. |
401 | No | Refresh or replace the API key. |
404 | No | Confirm the model, image, video, or job ID. |
409 | Maybe | Retry after the conflicting operation finishes. |
429 | Yes | Use exponential backoff and avoid starting too many active jobs. |
5xx | Yes | Retry with backoff; contact support if the issue keeps happening. |
For unresolved API issues, contact support@photogptai.com.