> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fanifyai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Generations

> Submit, track, list, and cancel Fanify Hub generations.

## Submit a generation

```bash theme={null}
curl https://fanifyai.com/api/v1/hub/generations \
  -H "Authorization: Bearer $FANIFY_API_KEY" \
  -H "Idempotency-Key: 0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11" \
  -H "Content-Type: application/json" \
  -d '{"model":"nano-banana-2","input":{"prompt":"a cat","aspect_ratio":"16:9","resolution":"2K"}}'
```

An accepted request returns `201`. V1 produces `queued`, `running`, `succeeded`, `failed`, and `canceled`. The `awaiting_supply` value is reserved for a future version and is never produced in V1.

<Tip>
  Use one stable, unique `Idempotency-Key` per generation. Replaying a completed request returns the existing generation with `200`.
</Tip>

Using the same key with a different body returns `422 idempotency_conflict`. An in-progress generation returns `503 generation_in_progress` with `Retry-After: 5`.

## Get and list generations

* `GET /api/v1/hub/generations/{id}` returns one generation.
* `GET /api/v1/hub/generations` lists the newest generations first.
* Available filters are `limit`, `cursor`, `status`, `from`, `to`, `model`, and `media_only`.
* `media_only=true` excludes LLM executions before pagination and the `total_billed` calculation.
* Use the opaque `next_cursor` unchanged to load the next page.

## Cancel a generation

`POST /api/v1/hub/generations/{id}/cancel` cancels only a `queued` generation. Other states return `409 not_cancelable`.

## Chat Completions compatibility

`POST /api/v1/hub/chat/completions` accepts OpenAI-compatible fields and forwards additional fields to the provider. Set `stream` to `false` or omit it. Omit the unsupported `n` parameter. A `200` response also includes:

```text theme={null}
X-Fanify-Generation-Id: 0192f3a4-8c1e-7b2a-9f10-2b6d4e0c9a11
X-Fanify-Billed-Cost: 0.000041
```

The alias also accepts `Idempotency-Key`. A completed replay returns the existing completion. An in-progress replay returns `503 generation_in_progress` with `Retry-After: 5`. Reusing the key with a different body returns `422 idempotency_conflict`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.