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

# Image generation API

## Before you start

Sign in to LuluLab and get a luk- API key from My Keys. Store it on your server. All examples call [https://customer.lululab.ai](https://customer.lululab.ai) and send the raw key in the Authorization header. [Get an API key](https://www.lululab.ai/keys)

Generation is asynchronous: POST /tasks returns a job id, then GET /tasks/\{id} provides status and output. You can call POST /billing/estimates before submitting to estimate credits.

Use ImageGenV2 for text-to-image or reference-image generation. prompt describes the image; referenceImages is optional. Choose a model-supported aspect ratio and resolution.

### When to use it

Submit an image job when you already have a visual description. To preserve a product appearance, upload its photo first and pass the returned location as referenceImages\[].url. Read the image result from the completed job output.

### Main request fields

| Field / type | Required | Values and description |
| - | - | - |
| `input.model` (`string`) | Yes | gpt-image-2-5-sunburst · gpt-image-2-5-flare · Image model ID; see supported combinations below. |
| `input.prompt` (`string`) | Yes | 1–20,000 characters · Describe subject, composition, setting, and style. The site limits prompts to 20,000 characters. |
| `input.aspectRatio` (`string`) | Yes | 1:1 · 16:9 · 9:16 · 4:3 · 3:4 · 3:2 · 2:3 · 5:4 · 4:5 · 2:1 · 1:2 · 21:9 · 9:21 · Target aspect ratio supported by the selected model. |
| `input.resolution` (`string`) | Yes | 1K · 2K · 4K · Target resolution; combine with a ratio supported by the model. |
| `input.referenceImages` (`array<MediaReference>`) | No | Optional reference images. Omit for text-to-image; each item includes url and mimeType. |

### Image models and allowed values

The current creation UI offers these models. Both provide 1K, 2K, and 4K with the ratios listed below.

`gpt-image-2-5-sunburst · gpt-image-2-5-flare`

Resolutions：`1K · 2K · 4K`\
Aspect ratios：`1:1 · 16:9 · 9:16 · 4:3 · 3:4 · 3:2 · 2:3 · 5:4 · 4:5 · 2:1 · 1:2 · 21:9 · 9:21`

```bash Image generation request theme={null}
curl -X POST https://customer.lululab.ai/tasks \
  -H "Authorization: $LULULAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "workflowId": "ImageGenV2",
    "input": {
      "model": "gpt-image-2-5-flare",
      "prompt": "Studio product photo of a ceramic cup on a clean table",
      "aspectRatio": "1:1",
      "resolution": "1K"
    },
    "attributes": { "saveGeneratedAssets": true, "creationSource": "api" }
  }'
```

> [!NOTE]
>
> This example generates an image from text. For image-to-image, follow the upload steps on the API overview and add referenceImages to input.

* [Upload reference assets](https://docs.lululab.ai/uploads.md)
* [Get task results and troubleshoot](https://docs.lululab.ai/task-results.md)
* [API reference](https://docs.lululab.ai/reference.md)


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