> 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 HyperFlow HI API.

# Errors

> The error format, every status and named code, and when to retry.

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 credits — top up to continue.",
    "type": "insufficient_quota",
    "code": "402"
  }
}
```

**Branch on the HTTP status, and show `message` to people.** On the inference endpoints (`/chat/completions`, `/embeddings`, `/images/*` and `POST /videos`), `code` is the HTTP status as a string, such as `"402"`. `GET /v1/models`, the video read endpoints, unknown paths and the per-address rate limit use the named codes in the table instead.

| Status       | Named code        | What happened                                                                                                | What to do                                                                                                      |
| ------------ | ----------------- | ------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------- |
| `400`        |                   | A parameter is wrong, the model doesn't take that content or option, or the model rejected the request       | Read the message: it names what to change. If the model itself rejected the request, the message says only that |
| `401`        | `invalid_api_key` | The key is missing, wrong or deleted                                                                         | Check the key, or create a new one                                                                              |
| `401`        | `key_disabled`    | The key is switched off                                                                                      | Switch it back on in [API keys](https://hi.hyperflow.fun/console/keys)                                          |
| `402`        |                   | Your available balance can't cover the request                                                               | [Top up](https://hi.hyperflow.fun/console/funding), or lower `max_tokens`                                       |
| `403`        |                   | A limit set on your account was reached                                                                      | Contact us on [Discord](https://discord.gg/GGDmD4K9CK)                                                          |
| `404`        | `not_found`       | No such model, video or endpoint                                                                             | Check the id against `GET /v1/models`, or the video id                                                          |
| `409`        | `video_not_ready` | The video isn't finished                                                                                     | Poll its status until it's `completed`                                                                          |
| `410`        | `video_expired`   | The video is past the time it's kept for                                                                     | Make it again, and download it sooner                                                                           |
| `413`        |                   | The request body is over 25 MB. The answer is an HTML page, not JSON                                         | Send a link, compress, or split the file                                                                        |
| `422`        |                   | The model made no image, for example because it declined the prompt                                          | Change the prompt, or try another image model                                                                   |
| `429`        | `rate_limited`    | Too many requests from your address. Too many from one key also returns `429`, without this code             | Slow down and retry with backoff                                                                                |
| `502`, `503` |                   | The model's hosts couldn't answer, billing was briefly unavailable, or a generated image couldn't be fetched | 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, HyperFlow HI 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.