---
title: "Error responses"
description: "Genflo API error responses by HTTP status and code: invalid API key, insufficient credits, task not found, invalid input and content safety rejections."
---

> Documentation Index
> Fetch the complete documentation index at: https://www.genflo.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Error responses

A request the API cannot accept returns an HTTP error status with a JSON body. A task that is created but fails later reports the failure in the task itself.

## Error body

Most errors return an `error` object with a machine-readable `code` and a readable `message`:

```json
{
  "error": {
    "code": "insufficient_credits",
    "message": "Not enough credits"
  }
}
```

Three kinds of error use another shape:

- A missing or invalid API key returns `{"detail": "Invalid API key"}`.
- A request body, or a `task_id` query parameter, that is missing or has the wrong type returns a `detail` list that names each invalid field.
- An `Authorization` header with an invalid or expired token, a request body larger than 2 MiB and an unexpected server error return a top-level `code` and `message`, for example `{"code": -1000, "message": "Request too large"}`.

## Error codes

| HTTP | Code | Meaning |
| --- | --- | --- |
| 401 | `detail` | The x-apikey header is missing or invalid. |
| 401 | `401` | The request has an `Authorization` header with an invalid or expired token. The body is `{"code": 401, "message": "Token Invalid"}`. Send only `x-apikey`. |
| 402 | `insufficient_credits` | The account does not have enough credits. |
| 404 | `task_not_found` | The task does not exist or belongs to another account. |
| 413 | `-1000` | The request body is larger than 2 MiB. |
| 422 | `detail` | The request body or the `task_id` query parameter is missing or has the wrong type. |
| 422 | `invalid_request` | The model alias or request input is invalid. |
| 422 | `credit_rate_not_found` | A video duration is missing or cannot be billed. |
| 422 | `sensitive_content` | The request was rejected by content safety checks. |
| 500 | `internal_error` | The gateway could not create the task. |
| 500 | `500` | An unexpected server error. The body is `{"code": 500, "message": "Server Error"}`. |

## Failed tasks

Generation runs after the creation request has returned HTTP 202, so a generation failure does not appear as an HTTP error. [Poll the task](/docs/task-status) instead: its `status` becomes `failed` or `rejected`, and its `error` is `{"code": "generation_failed", "message": "Generation failed"}`.

Source: https://www.genflo.io/docs/errors/index.mdx
