> Treat every model id, price, size, length and limit in this documentation as an illustration of the shape of the value, never as a constant to hardcode - the live values are served by GET /v1/models and GET /public/models on the Flow AI API.

# Errors

> What went wrong, and what to do about it.

Errors use OpenAI's shape, with a message written for you to read:

```json
{
  "error": {
    "message": "Your balance is too low for this request. Available: 0.42 THINK — top up to continue.",
    "type": "insufficient_quota",
    "code": "insufficient_balance"
  }
}
```

| Status       | Code                   | What happened                                                                                               | What to do                                                                             |
| ------------ | ---------------------- | ----------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- |
| `400`        | `invalid_request`      | A parameter is wrong, the model doesn't take that content, size or count, or the model rejected the request | Read the message; it names what to change                                              |
| `401`        | `invalid_api_key`      | The key is wrong or was deleted                                                                             | Check the key, or create a new one                                                     |
| `401`        | `key_disabled`         | The key is turned off                                                                                       | Turn it on in [API keys](https://ai.hyperflow.fun/console/keys)                        |
| `402`        | `insufficient_balance` | Your available balance can't cover the request                                                              | [Deposit](https://ai.hyperflow.fun/console/funds), or lower `max_tokens`               |
| `403`        |                        | The key's or the account's spending limit is reached                                                        | Raise it in [API keys](https://ai.hyperflow.fun/console/keys), or wait for it to reset |
| `404`        | `not_found`            | No such model or endpoint                                                                                   | Check the id against `GET /v1/models`                                                  |
| `409`        | `video_not_ready`      | The video isn't finished                                                                                    | Poll its status until it's `completed`                                                 |
| `429`        | `rate_limited`         | Too many requests from your address                                                                         | Slow down and retry with backoff                                                       |
| `502`, `503` | `host_unavailable`     | The model's hosts couldn't answer                                                                           | Retry shortly                                                                          |

## Retrying

Retry `429`, `502` and `503` with exponential backoff. The OpenAI SDKs do this for you. Don't retry `400` to `404` without changing something: they will fail the same way.

A refused request is never charged. A request that fails partway is charged for what the model already did.

## Hosts

When a model's host fails, Flow AI retries on another host for the same model where there is one, before returning an error. A host's own error is never passed on as is.