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

# Generate an image or video

> Submit a generation and poll it until the result is ready.

## Prerequisites

The same as for [calling a model](/agentic-banking/guides/call-a-model#prerequisites): an agent whose budget admits the inference provider, and that agent's API key.

## Choose a model

Pick an image or video model on the [Inference page](https://agentic.anchorage.com/inference), or from `GET https://inference.agentic.anchorage.com/v1/models`, where each callable model's `endpoint` names the path to submit it to. Skip entries whose `available` is `false`; the Inference page leaves them out. See [Choose a model](/agentic-banking/guides/call-a-model#choose-a-model).

## Submit the generation

```
POST https://inference.agentic.anchorage.com/v1/images/generations
Authorization: Bearer $AGENT_API_KEY
Content-Type: application/json
Idempotency-Key: <a new UUID per generation>

{"model": "...", "prompt": "..."}
```

For a video, send the same request to `/v1/videos/generations`.

* `model` is the identifier from the model list.
* `prompt` describes what to generate. It can't be blank.
* Any other field the model accepts, such as `n` and `size` for an image, is passed to the provider unchanged.
* `Idempotency-Key` is optional. Keep it for retries of this submit, and send a new one for the next generation.

## Poll for the result

```
GET https://inference.agentic.anchorage.com/v1/images/generations/{id}
Authorization: Bearer $AGENT_API_KEY
```

If the submit answered `202`, poll its `poll_url`, a path on `https://inference.agentic.anchorage.com`, every few seconds until `status` is `completed`, `failed`, or `timed_out`. A `completed` job carries its output in `data` when there is output to return. A job that ended with `payment_window_closed`, `payment_not_repeatable`, or `timed_out` can still turn `completed` for a day after its submit, so keep polling it now and then during that day to collect the output. Before you submit a failed or timed-out generation again, check its transaction; see [What a generation costs](/agentic-banking/concepts/inference#what-a-generation-costs).

Send the API key only to `https://inference.agentic.anchorage.com`: if a `poll_url` names any other host, don't poll it.

See [Image and video generation](/agentic-banking/concepts/inference#image-and-video-generation) for how polling, charging, retries, and errors work.


## Related topics

- [Call a model](/agentic-banking/guides/call-a-model.md)
- [Changelog](/agentic-banking/changelog.md)
- [Paid inference](/agentic-banking/concepts/inference.md)
- [Generate speech, sound effects, or music](/agentic-banking/guides/generate-audio.md)
- [Request a signed URL for document image upload](/knowledge-base/porto/api-reference/v2/onboarding/request-a-signed-url-for-document-image-upload.md)
