Start
Quickstart
Make a key, search, read the results, download, and generate only when nothing fits.
https://imgsearch.com/llms.txt
On this page
The examples read your key from IMGSEARCH_API_KEY and the base URL from IMGSEARCH_API_BASE (default https://imgsearch.com/api/v2). Ids that one call hands to the next come from environment variables too, each named in the example’s first lines. Python examples use httpx; JavaScript examples run on Node 18 or later.
Make a key #
- Sign in on the website and open Account → API keys. Any account with a verified email address can make keys.
- Name the key, pick its permissions (scopes) and how long it lasts: 30, 90 or 365 days. Confirm with your password (an account made with Google that never set one signs in again instead).
- Copy the key. It is shown once; the website keeps no copy you can read again.
An account can have 10 working keys at a time. Keep the key on your server; see keeping keys safe.
export IMGSEARCH_API_KEY="paste the key here"
Search #
Describe what you need in plain words: subject, setting, purpose and constraints. One search looks through every source at once (and your own generations, when the personal index is on).
# One search over every source, with what generating instead would cost.
# Needs IMGSEARCH_API_KEY.
curl -sS -X POST \
"${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/search" \
-H "Authorization: Bearer $IMGSEARCH_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "a red fox standing in fresh snow looking straight at the camera, shallow depth of field, early morning golden light, landscape",
"kind": "image",
"filters": {
"orientation": "landscape"
},
"limit": 5
}'
# One search over every source, with what generating instead would cost.
# 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}/search",
headers=headers,
json={
"query": "a red fox standing in fresh snow looking straight at the camera, shallow depth of field, early morning golden light, landscape",
"kind": "image",
"filters": {"orientation": "landscape"},
"limit": 5,
},
timeout=60,
)
print(r.status_code)
data = r.json()
print("complete:", data["complete"])
for item in data["results"]:
print(item["band"], item["relevance"], item["owned"], item["type"], item["id"], item["title"])
print("generating instead:", json.dumps(data["generation_estimate"]))
// One search over every source, with what generating instead would cost.
// Needs IMGSEARCH_API_KEY.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";
const r = await fetch(`${base}/search`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
query: "a red fox standing in fresh snow looking straight at the camera, shallow depth of field, early morning golden light, landscape",
kind: "image",
filters: { orientation: "landscape" },
limit: 5,
}),
});
const data = await r.json();
console.log(r.status, "complete:", data.complete);
for (const item of data.results) {
console.log(item.band, item.relevance, item.owned, item.type, item.id, item.title);
}
console.log("generating instead:", JSON.stringify(data.generation_estimate));
{
"object": "search_result",
"id": "srch_01m8bky7fv20mg1qk2fwk4aza5",
"complete": true,
"sources": {
"photo": {
"status": "ok",
"retryable": false
},
"video": {
"status": "ok",
"retryable": false
},
"svg": {
"status": "ok",
"retryable": false
},
"svg_pack": {
"status": "ok",
"retryable": false,
"ignored_filters": [
"orientation"
]
},
"brand": {
"status": "no_results",
"retryable": false
},
"sound_effect": {
"status": "no_results",
"retryable": false,
"ignored_filters": [
"orientation"
]
},
"sfx_pack": {
"status": "no_results",
"retryable": false,
"ignored_filters": [
"orientation"
]
},
"3d_model": {
"status": "no_results",
"retryable": false,
"ignored_filters": [
"orientation"
]
},
"3d_kit": {
"status": "no_results",
"retryable": false,
"ignored_filters": [
"orientation"
]
}
},
"results": [
{
"type": "photo",
"id": "majestic-red-fox-in-a-frosty-landscape-141601326",
"title": "Majestic red fox in a frosty landscape",
"description": "Explore the beauty of a majestic red fox captured in a frost-covered meadow, showcasing its fur keen demeanor amidst a winter landscape. Perfect for nature lovers wildlife enthusiasts.",
"relevance": 1,
"band": "strong",
"owned": true,
"made_by_you": false,
"community": false,
"preview_url": "https://imgsearch.com/api/v2/previews/EXAMPLE-SIGNED-LINK",
"page_url": "https://imgsearch.com/image/majestic-red-fox-in-a-frosty-landscape-141601326",
"format": "jpg",
"width": 2560,
"height": 1440,
"aspect_ratio": 1.7777777777777777,
"orientation": "landscape",
"tags": [
"red fox",
"frosty landscape",
"wildlife photography",
"nature",
"animal portrait",
"winter",
"meadow"
],
"delivered_size": "2560x1440",
"license": {
"key": "imgsearch_content",
"name": "ImgSearch content license",
"license_url": "https://imgsearch.com/legal",
"terms_url": "https://imgsearch.com/legal/terms",
"attribution": "optional",
"attribution_text": null,
"usage_conditions": null,
"not_allowed": [
"Files not obtained through a download",
"Showing identifiable people in a negative or offensive way",
"Suggesting endorsement by people or brands shown",
"Redistributing or selling the files on other stock-content or wallpaper platforms"
],
"ai_generated": true,
"community": false,
"notes": null
},
"download": {
"fair_use_units": 0,
"free": true,
"counter": "files"
}
},
{
"type": "video",
"id": "01kvptgeys1xt2vwk225f4xwqk",
"title": "Close-up of red fox looking up in forest",
"description": "A close-up view of a red fox in a natural outdoor setting. The fox turns its head to face forward, making direct eye contact, before tilting its snout upward to look at the sky. The background features soft, out-of-focus green foliage, highlighting the animal's bright orange and white fur.",
"relevance": 1,
"band": "strong",
"owned": false,
"made_by_you": false,
"community": false,
"preview_url": "https://imgsearch.com/api/v2/previews/EXAMPLE-SIGNED-LINK",
"page_url": "https://imgsearch.com/video/01kvptgeys1xt2vwk225f4xwqk",
"format": "mp4",
"width": 1280,
"height": 720,
"duration_seconds": 10,
"has_sound": true,
"tags": [
"nature",
"other"
],
"orientation": "landscape",
"poster_url": "https://cdn.imgsearch.com/batches/3/thumbnails/md/31930.webp?token=EXAMPLE&expires=EXAMPLE",
"license": {
"key": "imgsearch_content",
"name": "ImgSearch content license",
"license_url": "https://imgsearch.com/legal",
"terms_url": "https://imgsearch.com/legal/terms",
"attribution": "optional",
"attribution_text": null,
"usage_conditions": null,
"not_allowed": [
"Files not obtained through a download",
"Showing identifiable people in a negative or offensive way",
"Suggesting endorsement by people or brands shown",
"Redistributing or selling the files on other stock-content or wallpaper platforms"
],
"ai_generated": true,
"community": false,
"notes": null
},
"download": {
"fair_use_units": 1,
"free": false,
"counter": "videos"
}
},
{
"type": "video",
"id": "01kys82vwayth5gmvhgc36zck2",
"title": "Red fox in a lush green forest",
"description": "A red fox sits on a forest path surrounded by green foliage and white flowers. The fox looks around its environment before standing up and walking forward. Dappled sunlight filters through the trees, illuminating the fox's orange fur against the woodland backdrop.",
"relevance": 1,
"band": "strong",
"owned": false,
"made_by_you": false,
"community": false,
"preview_url": "https://imgsearch.com/api/v2/previews/EXAMPLE-SIGNED-LINK",
"page_url": "https://imgsearch.com/video/01kys82vwayth5gmvhgc36zck2",
"format": "mp4",
"width": 1280,
"height": 720,
"duration_seconds": 5,
"has_sound": true,
"tags": [
"nature",
"landscape"
],
"orientation": "landscape",
"poster_url": "https://cdn.imgsearch.com/batches/17/thumbnails/md/522528.webp?token=EXAMPLE&expires=EXAMPLE",
"license": {
"key": "imgsearch_content",
"name": "ImgSearch content license",
"license_url": "https://imgsearch.com/legal",
"terms_url": "https://imgsearch.com/legal/terms",
"attribution": "optional",
"attribution_text": null,
"usage_conditions": null,
"not_allowed": [
"Files not obtained through a download",
"Showing identifiable people in a negative or offensive way",
"Suggesting endorsement by people or brands shown",
"Redistributing or selling the files on other stock-content or wallpaper platforms"
],
"ai_generated": true,
"community": false,
"notes": null
},
"download": {
"fair_use_units": 1,
"free": false,
"counter": "videos"
}
},
{
"type": "photo",
"id": "majestic-winter-fox-in-snowfall-4934566",
"title": "Majestic winter fox in snowfall",
"description": "Stunning close-up of a red fox in snowy surroundings, highlighting its fur expressive eyes, perfect for wildlife photography enthusiasts.",
"relevance": 1,
"band": "strong",
"owned": false,
"made_by_you": false,
"community": false,
"preview_url": "https://imgsearch.com/api/v2/previews/EXAMPLE-SIGNED-LINK",
"page_url": "https://imgsearch.com/image/majestic-winter-fox-in-snowfall-4934566",
"format": "jpg",
"width": 2560,
"height": 1440,
"aspect_ratio": 1.7777777777777777,
"orientation": "landscape",
"tags": [
"fox",
"winter",
"snow",
"wildlife",
"red fox",
"nature",
"animal photography",
"serene landscape"
],
"delivered_size": "2560x1440",
"license": {
"key": "imgsearch_content",
"name": "ImgSearch content license",
"license_url": "https://imgsearch.com/legal",
"terms_url": "https://imgsearch.com/legal/terms",
"attribution": "optional",
"attribution_text": null,
"usage_conditions": null,
"not_allowed": [
"Files not obtained through a download",
"Showing identifiable people in a negative or offensive way",
"Suggesting endorsement by people or brands shown",
"Redistributing or selling the files on other stock-content or wallpaper platforms"
],
"ai_generated": true,
"community": false,
"notes": null
},
"download": {
"fair_use_units": 1,
"free": false,
"counter": "files"
}
},
{
"type": "photo",
"id": "majestic-winter-fox-in-snowy-landscape-71035802",
"title": "Majestic winter fox in snowy landscape",
"description": "Explore the beauty of nature with this captivating close-up of a red fox in a winter wonderland. This striking portrait showcases the fox's orange fur expressive eyes against a backdrop of soft white snow, making it a perfect representation of wildlife in winter.",
"relevance": 1,
"band": "strong",
"owned": false,
"made_by_you": false,
"community": false,
"preview_url": "https://imgsearch.com/api/v2/previews/EXAMPLE-SIGNED-LINK",
"page_url": "https://imgsearch.com/image/majestic-winter-fox-in-snowy-landscape-71035802",
"format": "jpg",
"width": 2560,
"height": 1440,
"aspect_ratio": 1.7777777777777777,
"orientation": "landscape",
"tags": [
"fox",
"wildlife",
"snow",
"nature",
"portrait",
"animal",
"red fox",
"winter",
"photography"
],
"delivered_size": "2560x1440",
"license": {
"key": "imgsearch_content",
"name": "ImgSearch content license",
"license_url": "https://imgsearch.com/legal",
"terms_url": "https://imgsearch.com/legal/terms",
"attribution": "optional",
"attribution_text": null,
"usage_conditions": null,
"not_allowed": [
"Files not obtained through a download",
"Showing identifiable people in a negative or offensive way",
"Suggesting endorsement by people or brands shown",
"Redistributing or selling the files on other stock-content or wallpaper platforms"
],
"ai_generated": true,
"community": false,
"notes": null
},
"download": {
"fair_use_units": 1,
"free": false,
"counter": "files"
}
}
],
"generation_estimate": {
"kind": "image",
"model": {
"id": "openai/gpt-image-2.5-sunburst",
"name": "GPT Image 2.5 Sunburst"
},
"options": {
"aspect_ratio": "16:9",
"quality": "medium",
"count": 1,
"style": "none"
},
"per_output_usd": 0.015,
"typical_seconds": 23,
"can_generate": true,
"reason": null
},
"fair_use": {
"status": "ok",
"videos_status": "ok",
"resets_at": "2026-12-07T14:57:00Z"
},
"next_cursor": "EXAMPLE-CURSOR",
"depth_limited": false
}
Read the results #
resultsare cards, best first. Read each one’sdescription(what the item actually shows), size andlicense.bandisstrong,possibleorweak, fromrelevance(0–1).strongusually fits when the description shows what was asked for;possibleneeds a closer look at the preview (preview_url). A source without fitted scores answersrelevanceandbandnull.owned: truemeans the account downloaded it before, so it is free again.made_by_you: truemarks your own generations.complete: falsemeans a source failed just now. Search again before you decide to generate.generation_estimateis what generating instead would cost with the default model, in US dollars, and whether this key could start it now.
More in search first.
Download #
Ask for signed links to the items you chose (up to 20 at a time). Nothing counts toward fair use until a link is fetched. The example takes one result’s type and id as ASSET_TYPE and ASSET_ID.
# A 10-minute download link per item; nothing counts until a link is fetched.
# Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
curl -sS -X POST \
"${IMGSEARCH_API_BASE:-https://imgsearch.com/api/v2}/downloads" \
-H "Authorization: Bearer $IMGSEARCH_API_KEY" \
-H "Content-Type: application/json" \
--data-binary @- <<EOF
{
"items": [
{
"type": "$ASSET_TYPE",
"id": "$ASSET_ID"
}
]
}
EOF
# A 10-minute download link per item; nothing counts until a link is fetched.
# Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_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}/downloads",
headers=headers,
json={"items": [{"type": os.environ["ASSET_TYPE"], "id": os.environ["ASSET_ID"]}]},
timeout=60,
)
print(r.status_code)
print(json.dumps(r.json(), indent=2))
// A 10-minute download link per item; nothing counts until a link is fetched.
// Needs IMGSEARCH_API_KEY, ASSET_TYPE and ASSET_ID.
const base = process.env.IMGSEARCH_API_BASE ?? "https://imgsearch.com/api/v2";
const r = await fetch(`${base}/downloads`, {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMGSEARCH_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ items: [{ type: process.env.ASSET_TYPE, id: process.env.ASSET_ID }] }),
});
console.log(r.status);
console.log(JSON.stringify(await r.json(), null, 2));
{
"object": "list",
"has_more": false,
"next_cursor": null,
"data": [
{
"status": "ready",
"url": "https://imgsearch.com/api/v2/files/EXAMPLE-SIGNED-LINK",
"expires_at": "2026-11-26T09:55:42Z",
"file_name": "majestic-red-fox-in-a-frosty-landscape-141601326.jpg",
"download": {
"fair_use_units": 0,
"free": true,
"counter": "files"
},
"object": "download_link",
"type": "photo",
"id": "majestic-red-fox-in-a-frosty-landscape-141601326",
"error": null
}
]
}
Fetch each link within 10 minutes. The link is the credential, so it needs no key. The example takes a link’s url as LINK_URL and saves the file under its file_name (FILE_NAME). Videos, sound packs and 3D kits answer with a redirect to a signed CDN address; the examples follow it:
# Fetches a signed download link (a url from POST /downloads) and saves it under the download's file_name. The link is
# the credential. Videos, sound packs and 3D kits answer 302 to a signed CDN address, which -L follows.
# Needs LINK_URL and FILE_NAME.
name="${FILE_NAME:-download}"
status=$(curl -sS -L -o "$name" -w '%{http_code}' "$LINK_URL")
echo "$status $name"
if [ "$status" != 200 ]; then
cat "$name"; rm -f "$name"
fi
# Fetches a signed download link (a url from POST /downloads) and saves it under the download's file_name. The link is
# the credential. Videos, sound packs and 3D kits answer 302 to a signed CDN address, which this follows.
# Needs LINK_URL and FILE_NAME.
import os
import httpx
name = os.environ.get("FILE_NAME") or "download"
r = httpx.get(os.environ["LINK_URL"], follow_redirects=True, timeout=60)
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)
// Fetches a signed download link (a url from POST /downloads) and saves it under the download's file_name. The link is
// the credential. Videos, sound packs and 3D kits answer 302 to a signed CDN address, which fetch follows.
// Needs LINK_URL and FILE_NAME.
import { writeFile } from "node:fs/promises";
const name = process.env.FILE_NAME || "download";
const r = await fetch(process.env.LINK_URL);
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());
GET /assets/{type}/{id}/file does the same in one call with the key. See assets and downloads.
Generate if nothing fits #
Generating spends AI balance, so it needs a key made with spending allowed (see spending). Check the price first:
# 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"
}
}'
# 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))
// 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));
{
"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
}
Then start it with the most the user allows it to cost, in US dollars, as max_usd, and an Idempotency-Key you keep, so a retry never charges twice:
# 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
}'
# 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))
// 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));
{
"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
}
To retry it safely, run it again with the same IDEMPOTENCY_KEY (the example prints the one it used); a run without it makes a new key and a new generation. The key can be any unique value up to 255 printable ASCII characters; the curl example makes one with uuidgen, or from /proc/sys/kernel/random/uuid where uuidgen is missing.
It answers at once with status: queued. Read it again after poll_after_seconds until it has succeeded (or failed, refunded in full). The example takes its id as GENERATION_ID:
# 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"
# 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))
// 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));
{
"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
}
Each output has a file_url and a download_url that work for 10 minutes. See generation.
The response examples on these pages come from a run against a local test server, where generation uses the test model
local/echo. Ids, times, models and prices in your answers will differ.
Next #
- Authentication and spending
- Search first
- Errors and limits
- Agent guides, to teach your coding agent the same steps