Skip to main content
The Deepshi API uses standard HTTP status codes. Errors return a JSON body with an error object describing what went wrong.
The code is a machine-readable string (for example invalid_api_key, model_not_found, or insufficient_quota), not the HTTP status, and it may be null. Match on the HTTP status code for routing, and on error.code for specifics.

Status codes

Rate limits

Request rate limits depend on your plan and apply across all of your API keys together. If you exceed your limit, requests return 429 until the window resets, and the blocked request is not charged. Back off and retry with exponential backoff (see below), and upgrade your plan for a higher limit.

Handling errors in code

Retry transient failures (429 and 5xx) with exponential backoff, and surface the others to the user:
Don’t retry 400, 401, 402, or 403. They won’t succeed on retry. Fix the request, key, balance, or model access instead.

Media-specific errors

A few errors are specific to the image, video, and music APIs:
  • 400 PROMPT_TOO_LONG: the prompt exceeds the model’s prompt_max_length. Each model’s limit is in GET /v1/models and on its model page. Shorten the prompt.
  • 400 for unsupported parameters or values: for example a resolution or duration the model doesn’t offer. Check the model’s allowed values in GET /v1/models.

Async job failures

Video and music jobs fail differently from synchronous requests. Creating the job succeeds, and the failure appears later, when polling: a normal 200 response with status: "failed" and an error object.
Always check status when polling; an HTTP-level check alone won’t catch it. A failed job is not charged. To retry, fix whatever the error describes and create a new job.