Errors & troubleshooting
Every failure the API returns, what it means, and whether retrying will help — including the credit rules that decide whether a failed call costs you anything.
Error shape
Failures use the same envelope as successes, with success: false and a human-readable message. Some errors add fields that tell you exactly what to do next.
{
"success": false,
"message": "Insufficient credits. You need 15 credits, but only have 4 credits available.",
"currentCredits": 4,
"requiredCredits": 15
}{
"success": false,
"isNsfw": true,
"message": "NSFW Content Detected: …",
"reason": "…",
"category": "…"
}Status codes
| Status | Meaning | Retry? |
|---|---|---|
400Bad request | A required parameter is missing, or the request was rejected before it reached a model. | No — fix the request |
400Insufficient credits | Valid key, empty balance. The body includes currentCredits and requiredCredits. | No — top up |
400Prompt rejected | The prompt failed the safety screen. The body includes isNsfw, reason and category. | No — rewrite the prompt |
401Unauthorized | No key, an invalid key, or a key that has been deleted. | No — fix credentials |
403Forbidden | The session or token is no longer valid for this account. | No — sign in again |
404Not found | The account behind the key no longer exists. | No |
500Provider or server error | The upstream model failed, timed out, or returned nothing usable. message carries the detail. | Yes — once or twice |
Common failures
Prompt is required— generation was called with an empty prompt. Onlyremove_bgandupscaleactions supply their own.Input image is required—edit,remove_background,upscale,compressandconvert_formatall needimage(orimageBase64).requests array is required—multicallwas called without a non-empty array.- A reference image URL that the server cannot fetch — use a publicly reachable https URL, or send the bytes as a base64 data URI.
- Tools missing in an MCP client — the client was not restarted, or the config JSON failed to parse.
Errors and credits
The order of operations matters. The balance is checked and credits are deducted before the request goes to a model, so an error raised at validation time costs nothing — but a failure after that point has already been charged.
- Rejected for a missing parameter, a bad key, or an insufficient balance → no credits taken.
- Rejected by the safety screen → no credits taken; the screen runs before the deduction.
- Deducted, then the model failed → credits already spent, and not returned automatically.
Do not loop on failures
Retry strategy
- Retry
500responses at most twice, with a short backoff. - Never retry
400or401— the request or the key has to change first. - In a
multicall, retry only the items whosesuccessisfalse; the rest already succeeded. - Read
userCreditsfrom the last successful response before retrying, so you know what is left to spend.
FAQ
Should my agent retry a failed generation?
Only for 5xx failures, and at most once or twice with backoff. Credits are deducted before the model runs, so a retry loop on a persistent failure spends the balance without producing an image.
Why did I get a 400 saying my prompt violates safety policies?
Prompts are screened before generation. The response includes isNsfw: true along with a reason and category. Rewrite the prompt rather than retrying it unchanged.
My call returned 401 but my key is correct.
Check the header is reaching the server intact — a stray space after "Bearer", a truncated copy-paste, or a deleted key are the usual causes. GET /auth/user-data is the cheapest way to test a key on its own.