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

# Image generation

> Generate and edit images with the best models.

Generate images with a single synchronous request. The response returns image
URLs (valid for 24 hours) and the cost of the generation.

## Generate

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.heyaskr.ai/v1/images/generations \
    -H "Authorization: Bearer ASKR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "model": "flux-1.1-pro",
      "prompt": "a red fox in a snowy forest, cinematic lighting",
      "size": "1024x1024",
      "n": 1
    }'
  ```

  ```python Python theme={null}
  import requests

  r = requests.post(
      "https://api.heyaskr.ai/v1/images/generations",
      headers={"Authorization": "Bearer ASKR_API_KEY"},
      json={
          "model": "flux-1.1-pro",
          "prompt": "a red fox in a snowy forest, cinematic lighting",
          "size": "1024x1024",
          "n": 1,
      },
  )
  print(r.json()["data"][0]["url"])
  ```
</CodeGroup>

## Parameters

<ParamField body="model" type="string" required>
  The image model id, e.g. `flux-1.1-pro`, `nano-banana`.
</ParamField>

<ParamField body="prompt" type="string" required>
  A text description of the image.
</ParamField>

<ParamField body="size" type="string">
  Dimensions, e.g. `1024x1024`. Or use `aspect_ratio` where supported.
</ParamField>

<ParamField body="n" type="integer" default="1">
  Number of images to generate.
</ParamField>

<ParamField body="negative_prompt" type="string">
  Things to avoid in the image (model dependent).
</ParamField>

## Response

```json theme={null}
{
  "data": [{ "url": "https://cdn.heyaskr.ai/images/...png" }],
  "cost": 0.0048
}
```

<Warning>
  Image URLs expire after 24 hours. Download and store any images you want to keep.
</Warning>
