# Reference to Image

**What**：Generate new images based on the subjects / style of reference images (image-to-image / multi-reference).

**When**：Use to keep a given character, product or style while changing the scene / composition; sending images means reference mode.

## Endpoints
- POST `/v1/images/generations`
- GET `/v1/images/generations/{id}`

> This page uses the unified API: generate with `POST /v1/images/generations` (synchronous by default: it returns once the image is ready; add `"async": true` to get a task back immediately and poll `GET /v1/images/generations/{id}`), authenticate with `Authorization: Bearer <key>`; errors use the OpenAI format. General notes are in the Images guide.

Synchronous (default): the server waits for the image and answers 200 with `data[].url`; if it is still not done after 110 seconds it answers 202 with the task object and a `Location` header. The task keeps running, so do not resubmit (there is no double charge); fetch the result with `GET /v1/images/generations/{id}`. Asynchronous (`"async": true` or the `Prefer: respond-async` header): answers 202 with the task object right away (`status: queued`, `Retry-After: 3`); poll with GET until `status` is `completed` or `failed`.

## Request params
| Param | Type | Required | Description |
| --- | --- | --- | --- |
| model | string | Yes | Sub-model: seedream-5.0-pro / seedream-5.0-lite / seedream-4.5 / seedream-4.0 |
| prompt | string | — | Image description (optional) |
| images | array | Yes | Reference image URL array (publicly reachable); limit per the table |
| resolution | string | — | 1K / 2K / 4K, only tiers priced in the table, default = lowest tier; accepted only by seedream-5.0-pro / seedream-5.0-lite / seedream-4.5 / seedream-4.0 (others use the default output and reject it) |
| aspect_ratio | string | — | Aspect ratio, e.g. 1:1 / 16:9 / 9:16 |
| negative_prompt / seed / enhancePrompt | string / integer / boolean | — | Negative prompt / random seed / auto-enhance prompt (optional) |
| size | string | — | `WIDTHxHEIGHT` (for example `1024x1024`): converted to the nearest aspect ratio the channel accepts; `aspect_ratio` wins when both are sent. nano / gemini also accept `auto`. |
| async | boolean | — | `true`: answer 202 with the task object right away, then poll with GET (the `Prefer: respond-async` header works too). Synchronous by default. |

## Sub-models

The tier price column is credits/image (credits/call for per-call models); (default output) = default output only, resolution not accepted; ≥N refs → = multi-reference tier.

| model | Usage | Materials | Images | Tier price (credits) |
| --- | --- | --- | --- | --- |
| `seedream-5.0-pro` | 5.0 Pro; quality first | ≤4 reference images | 1 | 2K=60 / 4K=72 ; +2/ref after 1 |
| `seedream-5.0-lite` | 5.0 Lite; 2K only | ≤4 reference images | 1 | 2K=22 |
| `seedream-4.5` | 4.5; 2K / 4K same price | ≤4 reference images | 1 | 2K=25 / 4K=25 |
| `seedream-4.0` | 4.0; 2K / 4K same price | ≤4 reference images | 1 | 2K=20 / 4K=20 |

> ⚠ seedream-5.0-pro: 1 image per call; seedream-5.0-lite: 1 image per call; seedream-4.5: 1 image per call; seedream-4.0: 1 image per call

`model`, `prompt`, `n`, `size`, `aspect_ratio`, `resolution`, `images`, `output_format`, `negative_prompt`, `prompt_extend` and `async` are the common fields; the server converts them to the channel fields. Other fields in the table are native to the channel: put them in the same body under their own names and they are passed through, and a native field wins over its unified synonym. `images` takes http(s) image URLs only (no base64). `response_format` can only be `url`.

## Request example
### Synchronous request (OpenAI SDK)

```bash
curl https://api.novapi.ai/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "seedream-5.0-pro",
  "prompt": "the same woman sitting in a cozy cafe by the window on a rainy day, soft light",
  "resolution": "2K",
  "images": [
    "https://cdn.novapi.ai/kling/1791949942892_d18ee23dfa3048e097c58c9c3e32a754.png"
  ],
  "aspect_ratio": "16:9"
}'
```

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.novapi.ai/v1", api_key="sk-...")

img = client.images.generate(
    model="seedream-5.0-pro",
    prompt="the same woman sitting in a cozy cafe by the window on a rainy day, soft light",
    extra_body={
        "resolution": "2K",
        "images": [
            "https://cdn.novapi.ai/kling/1791949942892_d18ee23dfa3048e097c58c9c3e32a754.png",
        ],
        "aspect_ratio": "16:9",
    },
)
print(img.data[0].url)
```

```ts
import OpenAI from "openai";

const client = new OpenAI({ baseURL: "https://api.novapi.ai/v1", apiKey: process.env.API_KEY });

const img = await client.images.generate({
  "model": "seedream-5.0-pro",
  "prompt": "the same woman sitting in a cozy cafe by the window on a rainy day, soft light",
  "resolution": "2K",
  "images": [
    "https://cdn.novapi.ai/kling/1791949942892_d18ee23dfa3048e097c58c9c3e32a754.png"
  ],
  "aspect_ratio": "16:9"
} as OpenAI.ImageGenerateParams);
console.log(img.data?.[0]?.url);
```

### Asynchronous request and polling

```bash
curl https://api.novapi.ai/v1/images/generations \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "seedream-5.0-pro",
  "prompt": "the same woman sitting in a cozy cafe by the window on a rainy day, soft light",
  "resolution": "2K",
  "images": [
    "https://cdn.novapi.ai/kling/1791949942892_d18ee23dfa3048e097c58c9c3e32a754.png"
  ],
  "aspect_ratio": "16:9",
  "async": true
}'
```

## Response example
### Response example (sync, 200)
```json
{
  "id": "img_<task-id>",
  "object": "image.generation",
  "model": "seedream-5.0-pro",
  "status": "completed",
  "created": <unix-seconds>,
  "completed_at": <unix-seconds>,
  "error": null,
  "data": [
    { "url": "https://..." }
  ]
}
```

### Response example (async, 202)
```json
{
  "id": "img_<task-id>",
  "object": "image.generation",
  "model": "seedream-5.0-pro",
  "status": "queued",
  "created": <unix-seconds>,
  "completed_at": null,
  "error": null,
  "data": []
}
```

```bash
curl https://api.novapi.ai/v1/images/generations/img_<task-id> \
  -H "Authorization: Bearer $API_KEY"

# status: queued | in_progress | completed | failed
# completed: data[].url holds the image URL(s); failed: error.code and error.message
```

## Response fields
| Field | Type | Description |
| --- | --- | --- |
| id | string | Task ID, starts with `img_`; used for polling. |
| object | string | Always `image.generation`. |
| model | string | The model from the request. |
| status | string | `queued`, `in_progress`, `completed` or `failed`. A synchronous 200 is always `completed`. |
| created | integer | Creation time (Unix seconds), as in OpenAI Images. |
| completed_at | integer \| null | Completion time; null until completed. |
| error | object \| null | On failure `{code, message}`, with `code` `image_generation_failed`. |
| data | array | When completed, `[{ "url": "https://..." }]`, one element per image (several when `n` is above 1, or for the 4 Midjourney images); an empty array until then. |
