# Generations

> The AI Generator, for keys made with spending allowed: estimate, start (Idempotency-Key and max_usd), poll, cancel, the files by 10-minute links, the free side actions and uploads.


## What a generation would cost, and whether this key could start it now

<a id="generations.estimate"></a>`generations.estimate`

`POST /generations/estimate`

Scope: `search`

The same body as POST /generations without max_usd. Writes nothing and charges nothing. can_generate is false with a reason when the account, the model, the site or this key's spending allowance stands in the way. price_usd equals what create charges, except a clip with aspect_ratio auto from a reference.url: its file's size is unknown here, so it is priced at the widest shape and the charge can be lower.

### Request body

`application/json`, [`GenerationEstimateRequest`](https://imgsearch.com/developers/reference/schemas.md#GenerationEstimateRequest)

| Field | Type | Required | Description |
|---|---|---|---|
| `kind` | string | Yes | One of: "image", "video", "audio", "meme", "music", "sound", "3d", "vector". |
| `model` | string or null | No | A model id from /models; the kind's default when left out. |
| `prompt` | string or null | No |  |
| `options` | object or null | No | The model's options, as /models/{id} lists them. |
| `reference` | GenerationReference | No | At most one picture to start from. |

### Responses

- `200` The price in US dollars. ([`GenerationEstimateResponse`](https://imgsearch.com/developers/reference/schemas.md#GenerationEstimateResponse))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# What this generation would cost, and whether this key could start it now. Charges nothing.
# Needs IMGSEARCH_API_KEY.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/estimate" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "image",
  "model": "openai/gpt-image-2.5-sunburst",
  "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
  "options": {
    "aspect_ratio": "16:9"
  }
}'
```

**Python**

```python
# What this generation would cost, and whether this key could start it now. Charges nothing.
# Needs IMGSEARCH_API_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/generations/estimate",
    headers=headers,
    json={
        "kind": "image",
        "model": "openai/gpt-image-2.5-sunburst",
        "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
        "options": {"aspect_ratio": "16:9"},
    },
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// What this generation would cost, and whether this key could start it now. Charges nothing.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/estimate`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    kind: "image",
    model: "openai/gpt-image-2.5-sunburst",
    prompt: "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
    options: { aspect_ratio: "16:9" },
  }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "generation_estimate",
    "kind": "image",
    "model": {
        "id": "local/echo",
        "name": "Local echo (test)"
    },
    "options": {
        "aspect_ratio": "16:9",
        "count": 1,
        "style": "none"
    },
    "price_usd": 0.01,
    "per_output_usd": 0.01,
    "outputs": 1,
    "typical_seconds": 3,
    "can_generate": true,
    "reason": null
}
```

## Your generations, newest first

<a id="generations.index"></a>`generations.index`

`GET /generations`

Scope: `generations:read`

Filters by kind, status, starred, model and words of the prompt or name (q; with the personal index on, close matches join). With ids (up to 20, comma separated) it answers those generations in that order instead, the cheap way to poll several at once; ids that are not yours are left out.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `ids` | query | string | No |  |
| `kind` | query | string | No | One of: image, video, audio, meme, music, sound, 3d, vector. |
| `status` | query | GenerationStatus | No | One of: queued, running, succeeded, failed, canceled. |
| `starred` | query | boolean | No | true (or 1) lists the starred generations, false (or 0) the others. |
| `model` | query | string | No |  |
| `q` | query | string | No |  |
| `limit` | query | integer | No | Items per page. |
| `cursor` | query | string | No | The next_cursor of the previous page, as it came. It works only for the same list, filter and account. |

### Responses

- `200` One page of generations. ([`List`](https://imgsearch.com/developers/reference/schemas.md#List))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Your generations by id (up to 20, comma separated): the cheap way to poll several.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations?ids=$GENERATION_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Your generations by id (up to 20, comma separated): the cheap way to poll several.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(f"{base}/generations", headers=headers, params={"ids": os.environ["GENERATION_ID"]}, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Your generations by id (up to 20, comma separated): the cheap way to poll several.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations?ids=${process.env.GENERATION_ID}`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "list",
    "data": [
        {
            "object": "generation",
            "id": "01m8bky93c0jbbax10h5qnjj0m",
            "kind": "image",
            "model": "local/echo",
            "model_name": "Local echo (test)",
            "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
            "title": null,
            "starred": false,
            "options": {
                "count": 1,
                "style": "none",
                "aspect_ratio": "16:9"
            },
            "status": "succeeded",
            "created_at": "2026-11-26T09:45:43Z",
            "started_at": "2026-11-26T09:45:43Z",
            "finished_at": "2026-11-26T09:45:44Z",
            "estimate_seconds": 3,
            "poll_after_seconds": null,
            "waiting": null,
            "error": null,
            "notice": null,
            "quoted_usd": 0.01,
            "charged_usd": 0.01,
            "refunded_usd": 0,
            "reference": null,
            "outputs": [
                {
                    "n": 0,
                    "mime": "image/png",
                    "width": 1344,
                    "height": 768,
                    "duration": null,
                    "bytes": 6627,
                    "triangles": null,
                    "lyrics": null,
                    "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
                    "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
                    "expires_at": "2026-11-26T09:55:44Z",
                    "upscale": {
                        "width": 2688,
                        "height": 1536,
                        "price_usd": 0.006
                    },
                    "upscaled": null
                }
            ],
            "exports": null,
            "soundtrack": null,
            "voiceover_video": null
        }
    ],
    "has_more": false,
    "next_cursor": null
}
```

## Start a generation (spends AI balance)

<a id="generations.store"></a>`generations.store`

`POST /generations`

Scope: `generate` · Idempotency-Key required · Spends AI balance

Follow these four steps for every need:
1. Search first. For any need for an image, illustration, icon, video, sound, music, voice or 3D model, search once per distinct need, in the user’s own generations and the ImgSearch library. Searching is free.
2. Inspect. Read each result’s description, size and license, and its band where one is given: strong usually fits when the description shows what was asked for; possible needs a closer look. Prefer results the user made or already owns, which cost nothing. If a search says it is incomplete, search again before deciding.
3. Reuse if one fits. Download only the items you chose.
4. Generate only if nothing fits, and only where generating is offered. Check the estimate first and stay within the most the user allowed; ask the user before going higher. If a request is refused for its content, tell the user; do not rephrase or retry it.
Needs a key made with spending allowed on the
website, an Idempotency-Key header and max_usd, the most the user allows this to cost in US dollars (a higher price
answers 409 price_above_max; ask the user before raising it). The same key and body again answers 200 with
Idempotent-Replayed and the same generation, charging nothing; the same key with another body answers 409
idempotency_conflict. The price is charged now and refunded in full if it fails. Poll GET /generations/{id}
after poll_after_seconds. content_refused means the content checks refused the request: never retry it or
rephrase it. Uploads and reference.url must be pictures the account holder has the rights to use. Memes come
without drawn captions: the captions come back in options.captions for you to draw.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `Idempotency-Key` | header | string | Yes | A value of your own, 1 to 255 printable ASCII characters, new for every new request. The same key and body again returns the same generation and charges nothing. |

### Request body

`application/json`, [`GenerationCreate`](https://imgsearch.com/developers/reference/schemas.md#GenerationCreate)

| Field | Type | Required | Description |
|---|---|---|---|
| `kind` | string | Yes | One of: "image", "video", "audio", "meme", "music", "sound", "3d", "vector". |
| `model` | string or null | No | A model id from /models; the kind's default when left out. |
| `prompt` | string or null | No |  |
| `options` | object or null | No | The model's options, as /models/{id} lists them. |
| `reference` | GenerationReference | No | At most one picture to start from. |
| `max_usd` | number | Yes | The most the user allows this generation to cost, in US dollars, with at most three decimals. At least 0, At most 1000. |

### Responses

- `201` Started and charged. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `200` The same request again; nothing was charged. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `402` plan_required, insufficient_balance or spend_cap_reached. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Starts a generation. max_usd is the most the user allows it to cost, in US dollars.
# Needs IMGSEARCH_API_KEY.
# To retry this same request without paying twice, run it again with the same IDEMPOTENCY_KEY.
IDEMPOTENCY_KEY="${IDEMPOTENCY_KEY:-$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)}"
echo "Idempotency-Key: $IDEMPOTENCY_KEY" >&2
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "kind": "image",
  "model": "openai/gpt-image-2.5-sunburst",
  "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
  "options": {
    "aspect_ratio": "16:9"
  },
  "max_usd": 0.02
}'
```

**Python**

```python
# Starts a generation. max_usd is the most the user allows it to cost, in US dollars.
# Needs IMGSEARCH_API_KEY.
import json
import os
import sys
import uuid

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
# To retry this same request without paying twice, run it again with the same IDEMPOTENCY_KEY.
idempotency_key = os.environ.get("IDEMPOTENCY_KEY") or str(uuid.uuid4())
print("Idempotency-Key:", idempotency_key, file=sys.stderr)
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}", "Idempotency-Key": idempotency_key}

r = httpx.post(
    f"{base}/generations",
    headers=headers,
    json={
        "kind": "image",
        "model": "openai/gpt-image-2.5-sunburst",
        "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
        "options": {"aspect_ratio": "16:9"},
        "max_usd": 0.02,
    },
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Starts a generation. max_usd is the most the user allows it to cost, in US dollars.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";
// To retry this same request without paying twice, run it again with the same IDEMPOTENCY_KEY.
const idempotencyKey = process.env.IDEMPOTENCY_KEY || crypto.randomUUID();
console.error("Idempotency-Key:", idempotencyKey);

const r = await fetch(`${base}/generations`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Idempotency-Key": idempotencyKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    kind: "image",
    model: "openai/gpt-image-2.5-sunburst",
    prompt: "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
    options: { aspect_ratio: "16:9" },
    max_usd: 0.02,
  }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 201**

```json
{
    "object": "generation",
    "id": "01m8bky93c0jbbax10h5qnjj0m",
    "kind": "image",
    "model": "local/echo",
    "model_name": "Local echo (test)",
    "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
    "title": null,
    "starred": false,
    "options": {
        "count": 1,
        "style": "none",
        "aspect_ratio": "16:9"
    },
    "status": "queued",
    "created_at": "2026-11-26T09:45:43Z",
    "started_at": null,
    "finished_at": null,
    "estimate_seconds": 3,
    "poll_after_seconds": 2,
    "waiting": {
        "reason": "busy",
        "ahead": 0
    },
    "error": null,
    "notice": null,
    "quoted_usd": 0.01,
    "charged_usd": 0.01,
    "refunded_usd": 0,
    "reference": null,
    "outputs": [],
    "exports": null,
    "soundtrack": null,
    "voiceover_video": null
}
```

## Upload a picture to use as a reference

<a id="uploads.store"></a>`uploads.store`

`POST /uploads`

Scope: `generate`

A JPEG, PNG or WebP of 64 to 4,096 pixels a side and at most 10 MB, as the multipart field file. It is kept for an hour; send its id as reference.upload_id. Only a key that may spend can upload, and only pictures the account holder has the rights to use, with everyone in them (or their parent or guardian) agreeing.

### Request body

`multipart/form-data`

| Field | Type | Required | Description |
|---|---|---|---|
| `file` | string | Yes |  |

### Responses

- `201` The upload. ([`Upload`](https://imgsearch.com/developers/reference/schemas.md#Upload))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Uploads a reference picture (JPEG, PNG or WebP) the account holder has the rights to use.
# Needs IMGSEARCH_API_KEY and UPLOAD_FILE.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/uploads" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -F "file=@$UPLOAD_FILE"
```

**Python**

```python
# Uploads a reference picture (JPEG, PNG or WebP) the account holder has the rights to use.
# Needs IMGSEARCH_API_KEY and UPLOAD_FILE.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(f"{base}/uploads", headers=headers, files={"file": open(os.environ["UPLOAD_FILE"], "rb")}, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Uploads a reference picture (JPEG, PNG or WebP) the account holder has the rights to use.
// Needs IMGSEARCH_API_KEY and UPLOAD_FILE.
import { readFile } from "node:fs/promises";

const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const form = new FormData();
form.append("file", new Blob([await readFile(process.env.UPLOAD_FILE)]), "reference.png");

const r = await fetch(`${base}/uploads`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
  body: form,
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 201**

```json
{
    "object": "upload",
    "id": "upl_01m8bky8xvhq169j1n8hme6ea0",
    "mime": "image/png",
    "width": 640,
    "height": 360,
    "bytes": 2064,
    "expires_at": "2026-11-26T10:45:43Z"
}
```

## One generation

<a id="generations.show"></a>`generations.show`

`GET /generations/{id}`

Scope: `generations:read`

Its status, outputs and their 10-minute file links. Send If-None-Match with the last ETag to get 304 while nothing changed. While it is queued or running, wait poll_after_seconds before the next read.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |
| `If-None-Match` | header | string | No | The last ETag you read; 304 while nothing changed. |

### Responses

- `200` The generation. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `304` Not changed since that ETag.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# One generation. Read it again after poll_after_seconds while it is queued or running.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# One generation. Read it again after poll_after_seconds while it is queued or running.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(f"{base}/generations/{os.environ['GENERATION_ID']}", headers=headers, timeout=60)
print(r.status_code, r.headers.get("etag"))
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// One generation. Read it again after poll_after_seconds while it is queued or running.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status, r.headers.get("etag"));
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "generation",
    "id": "01m8bky93c0jbbax10h5qnjj0m",
    "kind": "image",
    "model": "local/echo",
    "model_name": "Local echo (test)",
    "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
    "title": null,
    "starred": false,
    "options": {
        "count": 1,
        "style": "none",
        "aspect_ratio": "16:9"
    },
    "status": "succeeded",
    "created_at": "2026-11-26T09:45:43Z",
    "started_at": "2026-11-26T09:45:43Z",
    "finished_at": "2026-11-26T09:45:44Z",
    "estimate_seconds": 3,
    "poll_after_seconds": null,
    "waiting": null,
    "error": null,
    "notice": null,
    "quoted_usd": 0.01,
    "charged_usd": 0.01,
    "refunded_usd": 0,
    "reference": null,
    "outputs": [
        {
            "n": 0,
            "mime": "image/png",
            "width": 1344,
            "height": 768,
            "duration": null,
            "bytes": 6627,
            "triangles": null,
            "lyrics": null,
            "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
            "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
            "expires_at": "2026-11-26T09:55:44Z",
            "upscale": {
                "width": 2688,
                "height": 1536,
                "price_usd": 0.006
            },
            "upscaled": null
        }
    ],
    "exports": null,
    "soundtrack": null,
    "voiceover_video": null
}
```

## Delete a finished generation and its files

<a id="generations.destroy"></a>`generations.destroy`

`DELETE /generations/{id}`

Scope: `generations:write`

409 still_running while it is queued or running. Deleting frees its Idempotency-Key.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Responses

- `200` Deleted. ([`Deleted`](https://imgsearch.com/developers/reference/schemas.md#Deleted))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Deletes a finished generation and its files.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS -X DELETE \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Deletes a finished generation and its files.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.delete(f"{base}/generations/{os.environ['GENERATION_ID']}", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Deletes a finished generation and its files.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}`, {
  method: "DELETE",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "generation",
    "id": "01m8bkybpmrf86wntgby7kg6sg",
    "deleted": true
}
```

## Rename, star, or change a meme's captions

<a id="generations.update"></a>`generations.update`

`PATCH /generations/{id}`

Scope: `generations:write`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Request body

`application/json`, [`GenerationUpdate`](https://imgsearch.com/developers/reference/schemas.md#GenerationUpdate)

| Field | Type | Required | Description |
|---|---|---|---|
| `title` | string or null | No | Up to 80 characters; empty goes back to the prompt. |
| `starred` | boolean | No |  |
| `captions` | object or null | No | A meme's captions, each plain text of up to 120 characters; null keeps the saved ones, {} clears them. |
| `layout` | string | No | One of: "classic", "modern". |

### Responses

- `200` The generation. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Renames and stars a generation.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS -X PATCH \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "title": "Fox hero for the winter issue",
  "starred": true
}'
```

**Python**

```python
# Renames and stars a generation.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.patch(
    f"{base}/generations/{os.environ['GENERATION_ID']}",
    headers=headers,
    json={"title": "Fox hero for the winter issue", "starred": True},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Renames and stars a generation.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}`, {
  method: "PATCH",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ title: "Fox hero for the winter issue", starred: true }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "generation",
    "id": "01m8bky93c0jbbax10h5qnjj0m",
    "kind": "image",
    "model": "local/echo",
    "model_name": "Local echo (test)",
    "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
    "title": "Fox hero for the winter issue",
    "starred": true,
    "options": {
        "count": 1,
        "style": "none",
        "aspect_ratio": "16:9"
    },
    "status": "succeeded",
    "created_at": "2026-11-26T09:45:43Z",
    "started_at": "2026-11-26T09:45:43Z",
    "finished_at": "2026-11-26T09:45:44Z",
    "estimate_seconds": 3,
    "poll_after_seconds": null,
    "waiting": null,
    "error": null,
    "notice": null,
    "quoted_usd": 0.01,
    "charged_usd": 0.01,
    "refunded_usd": 0,
    "reference": null,
    "outputs": [
        {
            "n": 0,
            "mime": "image/png",
            "width": 1344,
            "height": 768,
            "duration": null,
            "bytes": 6627,
            "triangles": null,
            "lyrics": null,
            "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
            "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
            "expires_at": "2026-11-26T09:55:44Z",
            "upscale": {
                "width": 2688,
                "height": 1536,
                "price_usd": 0.006
            },
            "upscaled": null
        }
    ],
    "exports": null,
    "soundtrack": null,
    "voiceover_video": null
}
```

## Cancel a generation that has not started

<a id="generations.cancel"></a>`generations.cancel`

`POST /generations/{id}/cancel`

Scope: `generations:write`

Only while it is queued; its price is refunded in full. Anything else answers 409 not_cancelable.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Responses

- `200` The canceled generation. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Cancels a queued generation; its price comes back in full.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/cancel" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Cancels a queued generation; its price comes back in full.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(f"{base}/generations/{os.environ['GENERATION_ID']}/cancel", headers=headers, timeout=60)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Cancels a queued generation; its price comes back in full.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/cancel`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "generation",
    "id": "01m8bkybpmrf86wntgby7kg6sg",
    "kind": "image",
    "model": "local/echo",
    "model_name": "Local echo (test)",
    "prompt": "Examples replay to cancel",
    "title": null,
    "starred": false,
    "options": {
        "count": 1,
        "style": "none",
        "aspect_ratio": "1:1"
    },
    "status": "canceled",
    "created_at": "2026-11-26T09:45:46Z",
    "started_at": null,
    "finished_at": "2026-11-26T09:45:46Z",
    "estimate_seconds": 3,
    "poll_after_seconds": null,
    "waiting": null,
    "error": {
        "code": "canceled",
        "message": "Canceled before it started. Your $0.01 was refunded.",
        "retryable": false
    },
    "notice": null,
    "quoted_usd": 0.01,
    "charged_usd": 0,
    "refunded_usd": 0.01,
    "reference": null,
    "outputs": [],
    "exports": null,
    "soundtrack": null,
    "voiceover_video": null
}
```

## An output's file, to the bearer

<a id="generations.outputs"></a>`generations.outputs`

`GET /generations/{id}/outputs/{n}`

Scope: `generations:read`

The same file as its file_url. download=1 sends it as an attachment; format=png gives an SVG as PNG, format=wav a track as WAV, and a 3D model's exports by format and height once they are made.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |
| `n` | path | string | Yes | An output's n (its place in outputs, counting from 0, so the first is 0), or soundtrack, video-clip, video-loop, video-bounce or video-hold. |
| `download` | query | boolean | No |  |
| `format` | query | string | No |  |
| `height` | query | string | No |  |

### Responses

- `200` The file.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Saves one output's file (OUTPUT_N is its n, usually 0).
# Needs IMGSEARCH_API_KEY, GENERATION_ID and OUTPUT_N.
curl -sS -OJ \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/outputs/$OUTPUT_N?download=1" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# Saves one output's file (OUTPUT_N is its n, usually 0).
# Needs IMGSEARCH_API_KEY, GENERATION_ID and OUTPUT_N.
import os
import re

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(
    f"{base}/generations/{os.environ['GENERATION_ID']}/outputs/{os.environ['OUTPUT_N']}",
    headers=headers,
    params={"download": "1"},
    timeout=60,
)
match = re.search(r'filename="?([^";]+)', r.headers.get("content-disposition", ""))
name = match.group(1) if match else "output"
if r.status_code == 200:
    open(name, "wb").write(r.content)
print(r.status_code, r.headers.get("content-type"), len(r.content), "bytes", name if r.status_code == 200 else r.text)
```

**JavaScript**

```js
// Saves one output's file (OUTPUT_N is its n, usually 0).
// Needs IMGSEARCH_API_KEY, GENERATION_ID and OUTPUT_N.
import { writeFile } from "node:fs/promises";

const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/outputs/${process.env.OUTPUT_N}?download=1`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
const match = /filename="?([^";]+)/.exec(r.headers.get("content-disposition") ?? "");
const name = match ? match[1] : "output";
const bytes = Buffer.from(await r.arrayBuffer());
if (r.status === 200) await writeFile(name, bytes);
console.log(r.status, r.headers.get("content-type"), bytes.length, "bytes", r.status === 200 ? name : bytes.toString());
```

## Upscale one of a generation's pictures 2× (spends AI balance)

<a id="generations.upscale"></a>`generations.upscale`

`POST /generations/{id}/upscale`

Scope: `generate` · Idempotency-Key required · Spends AI balance

Its price is the output's upscale.price_usd. Needs an Idempotency-Key and max_usd, like POST /generations. A picture already upscaled or being upscaled answers 200 with that generation, without Idempotent-Replayed, and charges nothing.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |
| `Idempotency-Key` | header | string | Yes | A value of your own, 1 to 255 printable ASCII characters, new for every new request. The same key and body again returns the same generation and charges nothing. |

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `n` | integer | No | At least 0, At most 9. Default 0. |
| `max_usd` | number | Yes | The most the user allows this to cost, in US dollars, with at most three decimals. At least 0, At most 1000. |

### Responses

- `201` The upscale, started and charged. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `200` The same request again (Idempotent-Replayed), or the picture's existing upscale. ([`Generation`](https://imgsearch.com/developers/reference/schemas.md#Generation))
- `402` plan_required, insufficient_balance or spend_cap_reached. ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Upscales picture n 2x. Its price is the output's upscale.price_usd.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
# To retry this same request without paying twice, run it again with the same IDEMPOTENCY_KEY.
IDEMPOTENCY_KEY="${IDEMPOTENCY_KEY:-$(uuidgen 2>/dev/null || cat /proc/sys/kernel/random/uuid)}"
echo "Idempotency-Key: $IDEMPOTENCY_KEY" >&2
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/upscale" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "n": 0,
  "max_usd": 0.1
}'
```

**Python**

```python
# Upscales picture n 2x. Its price is the output's upscale.price_usd.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os
import sys
import uuid

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
# To retry this same request without paying twice, run it again with the same IDEMPOTENCY_KEY.
idempotency_key = os.environ.get("IDEMPOTENCY_KEY") or str(uuid.uuid4())
print("Idempotency-Key:", idempotency_key, file=sys.stderr)
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}", "Idempotency-Key": idempotency_key}

r = httpx.post(
    f"{base}/generations/{os.environ['GENERATION_ID']}/upscale",
    headers=headers,
    json={"n": 0, "max_usd": 0.1},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Upscales picture n 2x. Its price is the output's upscale.price_usd.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";
// To retry this same request without paying twice, run it again with the same IDEMPOTENCY_KEY.
const idempotencyKey = process.env.IDEMPOTENCY_KEY || crypto.randomUUID();
console.error("Idempotency-Key:", idempotencyKey);

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/upscale`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Idempotency-Key": idempotencyKey,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ n: 0, max_usd: 0.1 }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 201**

```json
{
    "object": "generation",
    "id": "01m8bkyafh25zkcvsn64kg08we",
    "kind": "image",
    "model": "fal-ai/seedvr/upscale/image",
    "model_name": "Upscale 2×",
    "prompt": "A red fox standing in fresh snow at sunrise, wide shot, empty space on the left for a headline",
    "title": null,
    "starred": false,
    "options": {
        "upscale": 2
    },
    "status": "queued",
    "created_at": "2026-11-26T09:45:45Z",
    "started_at": null,
    "finished_at": null,
    "estimate_seconds": 15,
    "poll_after_seconds": 5,
    "waiting": {
        "reason": "busy",
        "ahead": 1
    },
    "error": null,
    "notice": null,
    "quoted_usd": 0.006,
    "charged_usd": 0.006,
    "refunded_usd": 0,
    "reference": {
        "type": "generation",
        "id": "01m8bky93c0jbbax10h5qnjj0m",
        "n": 0
    },
    "outputs": [],
    "exports": null,
    "soundtrack": null,
    "voiceover_video": null
}
```

## A 3D model in another format (free)

<a id="generations.exports.store"></a>`generations.exports.store`

`POST /generations/{id}/exports`

Scope: `generations:write`

202 while it is being made (read it again), 200 once it is ready.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `format` | string | Yes | One of: "fbx", "obj", "usdz", "glb", "glb-1k". |
| `height_m` | number or null | No | At least 0.05, At most 100. |

### Responses

- `200` Ready. ([`Export`](https://imgsearch.com/developers/reference/schemas.md#Export))
- `202` Being made. ([`Export`](https://imgsearch.com/developers/reference/schemas.md#Export))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Asks for a 3D model as FBX (free). 202 while it is made, 200 once it is ready.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/exports" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "format": "fbx"
}'
```

**Python**

```python
# Asks for a 3D model as FBX (free). 202 while it is made, 200 once it is ready.
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/generations/{os.environ['GENERATION_ID']}/exports",
    headers=headers,
    json={"format": "fbx"},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Asks for a 3D model as FBX (free). 202 while it is made, 200 once it is ready.
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/exports`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ format: "fbx" }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "export",
    "key": "fbx-asis",
    "format": "fbx",
    "height_m": null,
    "status": "succeeded",
    "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
    "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
    "expires_at": "2026-11-26T09:55:45Z",
    "bytes": 12156,
    "error": null
}
```

## One export's state and links

<a id="generations.exports.show"></a>`generations.exports.show`

`GET /generations/{id}/exports/{key}`

Scope: `generations:read`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |
| `key` | path | string | Yes | The format and height, such as fbx-asis or glb-1.80. |

### Responses

- `200` The export. ([`Export`](https://imgsearch.com/developers/reference/schemas.md#Export))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# One export's state and links (EXPORT_KEY as fbx-asis).
# Needs IMGSEARCH_API_KEY, GENERATION_ID and EXPORT_KEY.
curl -sS \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/exports/$EXPORT_KEY" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY"
```

**Python**

```python
# One export's state and links (EXPORT_KEY as fbx-asis).
# Needs IMGSEARCH_API_KEY, GENERATION_ID and EXPORT_KEY.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.get(
    f"{base}/generations/{os.environ['GENERATION_ID']}/exports/{os.environ['EXPORT_KEY']}",
    headers=headers,
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// One export's state and links (EXPORT_KEY as fbx-asis).
// Needs IMGSEARCH_API_KEY, GENERATION_ID and EXPORT_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/exports/${process.env.EXPORT_KEY}`, {
  headers: { Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}` },
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "export",
    "key": "fbx-asis",
    "format": "fbx",
    "height_m": null,
    "status": "succeeded",
    "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
    "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
    "expires_at": "2026-11-26T09:55:45Z",
    "bytes": 12156,
    "error": null
}
```

## View a 3D model in AR (free)

<a id="generations.ar"></a>`generations.ar`

`POST /generations/{id}/ar`

Scope: `generations:write`

Signed 30-minute links for iOS Quick Look and Android Scene Viewer; 202 while they are being made.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `height_m` | number or null | No |  |
| `retry` | boolean | No |  |

### Responses

- `200` Ready. ([`ArLinks`](https://imgsearch.com/developers/reference/schemas.md#ArLinks))
- `202` Being made. ([`ArLinks`](https://imgsearch.com/developers/reference/schemas.md#ArLinks))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# View in AR links for a 3D model, 1.2 m tall (free).
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/ar" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "height_m": 1.2
}'
```

**Python**

```python
# View in AR links for a 3D model, 1.2 m tall (free).
# Needs IMGSEARCH_API_KEY and GENERATION_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/generations/{os.environ['GENERATION_ID']}/ar",
    headers=headers,
    json={"height_m": 1.2},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// View in AR links for a 3D model, 1.2 m tall (free).
// Needs IMGSEARCH_API_KEY and GENERATION_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/ar`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ height_m: 1.2 }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "ar_links",
    "status": "succeeded",
    "ios_url": "https://imgsearch.com/generator/ar/01m8bkxnmvbtztw64v4jc0b3jb/0.usdz?expires=EXAMPLE&height=1.20&user=22378&signature=EXAMPLE",
    "android_url": "https://imgsearch.com/generator/ar/01m8bkxnmvbtztw64v4jc0b3jb/0.glb?expires=EXAMPLE&height=1.20&user=22378&signature=EXAMPLE",
    "expires_at": "2026-11-26T10:15:45Z",
    "error": null
}
```

## Put one of your tracks (and a voiceover) on a clip (free)

<a id="generations.soundtrack"></a>`generations.soundtrack`

`POST /generations/{id}/soundtrack`

Scope: `generations:write`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `music_id` | string | Yes |  |
| `voice_id` | string or null | No |  |
| `n` | integer | No | At least 0, At most 9. |
| `volume` | integer | No | At least 0, At most 100. |
| `music_start` | number | No | At least 0. |
| `fade` | boolean | No |  |
| `duck` | boolean | No |  |
| `clip_sound` | boolean | No |  |

### Responses

- `200` Ready. ([`Soundtrack`](https://imgsearch.com/developers/reference/schemas.md#Soundtrack))
- `202` Being mixed. ([`Soundtrack`](https://imgsearch.com/developers/reference/schemas.md#Soundtrack))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Lays one of your tracks (MUSIC_ID) on a clip (GENERATION_ID). Free.
# Needs IMGSEARCH_API_KEY, GENERATION_ID and MUSIC_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/soundtrack" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<EOF
{
  "music_id": "$MUSIC_ID",
  "volume": 60,
  "fade": true
}
EOF
```

**Python**

```python
# Lays one of your tracks (MUSIC_ID) on a clip (GENERATION_ID). Free.
# Needs IMGSEARCH_API_KEY, GENERATION_ID and MUSIC_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/generations/{os.environ['GENERATION_ID']}/soundtrack",
    headers=headers,
    json={"music_id": os.environ["MUSIC_ID"], "volume": 60, "fade": True},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Lays one of your tracks (MUSIC_ID) on a clip (GENERATION_ID). Free.
// Needs IMGSEARCH_API_KEY, GENERATION_ID and MUSIC_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/soundtrack`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ music_id: process.env.MUSIC_ID, volume: 60, fade: true }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "soundtrack",
    "status": "succeeded",
    "n": 0,
    "music_id": "01m8bkxncmn3vg8hfznkpy1f65",
    "voice_id": null,
    "volume": 60,
    "music_start": 0,
    "fade": true,
    "duck": false,
    "clip_sound": true,
    "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
    "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
    "error": null
}
```

## Lay a finished voiceover on one of your clips (free)

<a id="generations.voiceover-video"></a>`generations.voiceover-video`

`POST /generations/{id}/voiceover-video`

Scope: `generations:write`

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | Yes | A generation's id. |

### Request body

`application/json`

| Field | Type | Required | Description |
|---|---|---|---|
| `video_id` | string or null | No |  |
| `n` | integer or null | No | At least 0, At most 9. |

### Responses

- `200` Ready. ([`VoiceoverVideo`](https://imgsearch.com/developers/reference/schemas.md#VoiceoverVideo))
- `202` Being made. ([`VoiceoverVideo`](https://imgsearch.com/developers/reference/schemas.md#VoiceoverVideo))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Lays a finished voiceover (GENERATION_ID) on one of your clips (VIDEO_ID). Free.
# Needs IMGSEARCH_API_KEY, GENERATION_ID and VIDEO_ID.
curl -sS -X POST \
  "${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/generations/$GENERATION_ID/voiceover-video" \
  -H "Authorization: Bearer $IMGSEARCH_API_KEY" \
  -H "Content-Type: application/json" \
  --data-binary @- <<EOF
{
  "video_id": "$VIDEO_ID"
}
EOF
```

**Python**

```python
# Lays a finished voiceover (GENERATION_ID) on one of your clips (VIDEO_ID). Free.
# Needs IMGSEARCH_API_KEY, GENERATION_ID and VIDEO_ID.
import json
import os

import httpx

base = os.environ.get("IMGSEARCH_API_BASE", "https://imgsearch.com/api/v2")
headers = {"Authorization": f"Bearer {os.environ['IMGSEARCH_API_KEY']}"}

r = httpx.post(
    f"{base}/generations/{os.environ['GENERATION_ID']}/voiceover-video",
    headers=headers,
    json={"video_id": os.environ["VIDEO_ID"]},
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Lays a finished voiceover (GENERATION_ID) on one of your clips (VIDEO_ID). Free.
// Needs IMGSEARCH_API_KEY, GENERATION_ID and VIDEO_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";

const r = await fetch(`${base}/generations/${process.env.GENERATION_ID}/voiceover-video`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ video_id: process.env.VIDEO_ID }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 200**

```json
{
    "object": "voiceover_video",
    "status": "succeeded",
    "video_id": "01m8bkxnatzr40rjsk4hk318eb",
    "n": 0,
    "files": [
        {
            "fit": "clip",
            "file_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK",
            "download_url": "https://imgsearch.com/api/v2/generation-files/EXAMPLE-SIGNED-LINK"
        }
    ],
    "error": null
}
```

## Fetch one of your generation files by its signed link

<a id="generation-files.show"></a>`generation-files.show`

`GET /generation-files/{token}`

No key needed

A file_url or download_url of a generation: it works for 10 minutes, for the account and the key or token that read it, and stops when either is revoked.

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `token` | path | string | Yes |  |

### Responses

- `200` The file.
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Fetches a generation's file_url or download_url. The link is the credential.
# Needs LINK_URL.
curl -sS -o generation-file -w '%{http_code} %{content_type}\n' \
  "$LINK_URL"
```

**Python**

```python
# Fetches a generation's file_url or download_url. The link is the credential.
# Needs LINK_URL.
import os
import re

import httpx

r = httpx.get(os.environ["LINK_URL"], timeout=60)
match = re.search(r'filename="?([^";]+)', r.headers.get("content-disposition", ""))
name = match.group(1) if match else "generation-file"
if r.status_code == 200:
    open(name, "wb").write(r.content)
print(r.status_code, r.headers.get("content-type"), len(r.content), "bytes", name if r.status_code == 200 else r.text)
```

**JavaScript**

```js
// Fetches a generation's file_url or download_url. The link is the credential.
// Needs LINK_URL.
import { writeFile } from "node:fs/promises";

const r = await fetch(process.env.LINK_URL);
const match = /filename="?([^";]+)/.exec(r.headers.get("content-disposition") ?? "");
const name = match ? match[1] : "generation-file";
const bytes = Buffer.from(await r.arrayBuffer());
if (r.status === 200) await writeFile(name, bytes);
console.log(r.status, r.headers.get("content-type"), bytes.length, "bytes", r.status === 200 ? name : bytes.toString());
```

## Upload a reference picture to a signed upload link

<a id="upload-links.store"></a>`upload-links.store`

`PUT /upload-links/{token}`

No key needed

The upload_url that MCP 3.0's prepare_upload returns: the link is the credential. PUT the picture's bytes as the body, with the Content-Type the link was made for (image/jpeg, image/png or image/webp) and at most its size, within 15 minutes. A link works once: a second PUT answers 404. The answer is the upload; send its id as reference.upload_id within an hour. It counts toward the upload limit (429 rate_limited) and passes the same checks as POST /uploads (422 invalid_request, fields.file).

### Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `token` | path | string | Yes |  |

### Request body

`image/jpeg`

### Responses

- `201` The upload. ([`Upload`](https://imgsearch.com/developers/reference/schemas.md#Upload))
- `default` Error envelope ([`Error`](https://imgsearch.com/developers/reference/schemas.md#Error))

### Examples

**curl**

```bash
# Sends a picture to an upload_url from the MCP server's prepare_upload, with the type the link was made for.
# Needs LINK_URL and UPLOAD_FILE.
curl -sS -X PUT \
  "$LINK_URL" \
  -H "Content-Type: image/png" \
  --data-binary "@$UPLOAD_FILE"
```

**Python**

```python
# Sends a picture to an upload_url from the MCP server's prepare_upload, with the type the link was made for.
# Needs LINK_URL and UPLOAD_FILE.
import json
import os

import httpx

headers = {"Content-Type": "image/png"}

r = httpx.put(
    os.environ["LINK_URL"],
    headers=headers,
    content=open(os.environ["UPLOAD_FILE"], "rb").read(),
    timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
```

**JavaScript**

```js
// Sends a picture to an upload_url from the MCP server's prepare_upload, with the type the link was made for.
// Needs LINK_URL and UPLOAD_FILE.
import { readFile } from "node:fs/promises";

const r = await fetch(process.env.LINK_URL, {
  method: "PUT",
  headers: { "Content-Type": "image/png" },
  body: await readFile(process.env.UPLOAD_FILE),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
```

**Response 201**

```json
{
    "object": "upload",
    "id": "upl_01m6v2m7ah186jeyq7nb8e3m7r",
    "mime": "image/png",
    "width": 640,
    "height": 360,
    "bytes": 2064,
    "expires_at": "2026-11-07T14:19:35Z"
}
```
