Generator

Menu

AI GeneratorImages, video, audio and 3D

Browse categories

Docs menu
Generations

API reference

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.

View as Markdown
For your agent https://imgsearch.com/llms.txt
On this page
POST /generations/estimate

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

  • generations.estimate
  • 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

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

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

GET /generations

Your generations, newest first #

  • generations.index
  • 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

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

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /generations

Start a generation (spends AI balance) #

  • generations.store
  • 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

NameInTypeDescription
Idempotency-Keyrequired header string 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

FieldTypeDescription
kindrequired string One of: image, video, audio, meme, music, sound, 3d, vector
model string or null A model id from /models; the kind's default when left out.
prompt string or null
options object or null The model's options, as /models/{id} lists them.
reference GenerationReference At most one picture to start from.
max_usdrequired number 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)
  • 200 The same request again; nothing was charged. (Generation)
  • 402 plan_required, insufficient_balance or spend_cap_reached. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /uploads

Upload a picture to use as a reference #

  • uploads.store
  • 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

FieldTypeDescription
filerequired string

Responses

Examples

curl
# 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
# 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
// 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
{
    "object": "upload",
    "id": "upl_01m8bky8xvhq169j1n8hme6ea0",
    "mime": "image/png",
    "width": 640,
    "height": 360,
    "bytes": 2064,
    "expires_at": "2026-11-26T10:45:43Z"
}
Try it

The try-it panel needs JavaScript.

GET /generations/{id}

One generation #

  • generations.show
  • 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

NameInTypeDescription
idrequired path string A generation's id.
If-None-Match header string The last ETag you read; 304 while nothing changed.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

DELETE /generations/{id}

Delete a finished generation and its files #

  • generations.destroy
  • generations:write

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

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Responses

Examples

curl
# 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
# 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
// 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
{
    "object": "generation",
    "id": "01m8bkybpmrf86wntgby7kg6sg",
    "deleted": true
}
Try it

The try-it panel needs JavaScript.

PATCH /generations/{id}

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

  • generations.update
  • generations:write

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Request body

application/json, GenerationUpdate

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

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /generations/{id}/cancel

Cancel a generation that has not started #

  • generations.cancel
  • generations:write

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

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

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

An output's file, to the bearer #

  • generations.outputs
  • 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

NameInTypeDescription
idrequired path string A generation's id.
nrequired path string 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
format query string
height query string

Responses

Examples

curl
# 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
# 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
// 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());
Try it

The try-it panel needs JavaScript.

POST /generations/{id}/upscale

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

  • generations.upscale
  • 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

NameInTypeDescription
idrequired path string A generation's id.
Idempotency-Keyrequired header string 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

FieldTypeDescription
n integer At least 0, At most 9. Default 0.
max_usdrequired number 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)
  • 200 The same request again (Idempotent-Replayed), or the picture's existing upscale. (Generation)
  • 402 plan_required, insufficient_balance or spend_cap_reached. (Error)
  • Error Error envelope (error codes)

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /generations/{id}/exports

A 3D model in another format (free) #

  • generations.exports.store
  • generations:write

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

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Request body

application/json

FieldTypeDescription
formatrequired string One of: fbx, obj, usdz, glb, glb-1k
height_m number or null At least 0.05, At most 100.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

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

One export's state and links #

  • generations.exports.show
  • generations:read

Parameters

NameInTypeDescription
idrequired path string A generation's id.
keyrequired path string The format and height, such as fbx-asis or glb-1.80.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /generations/{id}/ar

View a 3D model in AR (free) #

  • generations.ar
  • generations:write

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

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Request body

application/json

FieldTypeDescription
height_m number or null
retry boolean

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /generations/{id}/soundtrack

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

  • generations.soundtrack
  • generations:write

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Request body

application/json

FieldTypeDescription
music_idrequired string
voice_id string or null
n integer At least 0, At most 9.
volume integer At least 0, At most 100.
music_start number At least 0.
fade boolean
duck boolean
clip_sound boolean

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

POST /generations/{id}/voiceover-video

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

  • generations.voiceover-video
  • generations:write

Parameters

NameInTypeDescription
idrequired path string A generation's id.

Request body

application/json

FieldTypeDescription
video_id string or null
n integer or null At least 0, At most 9.

Responses

Examples

curl
# 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
# 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
// 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
{
    "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
}
Try it

The try-it panel needs JavaScript.

GET /generation-files/{token}

Fetch one of your generation files by its signed link #

  • generation-files.show
  • 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

NameInTypeDescription
tokenrequired path string

Responses

Examples

curl
# 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
# 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
// 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());
PUT /upload-links/{token}

Upload a reference picture to a signed upload link #

  • upload-links.store
  • 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

NameInTypeDescription
tokenrequired path string

Request body

image/jpeg

Responses

Examples

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