How to send requests to the ImagineArt API and handle what comes back.
The ImagineArt API generates images and videos with ImagineArt models, runs creator-built Apps, and reports usage per key.
Successful responses wrap their payload in data; lists add pagination.
{ "status": "success", "data": { } }
Three steps take you from a new key to a finished image.
Create a key under API keys. Keep it on your server, never in browser or app code.
export IMAGINE_API_KEY="your-api-key"
curl -X POST https://api.imagine.art/v1/image/generate \ -H "Authorization: Bearer $IMAGINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "imagineart-2.0", "input": { "prompt": "A red convertible above Cinque Terre at golden hour", "aspect_ratio": "16:9" } }'
The API answers 202 at once with an id and data.status set to pending.
curl https://api.imagine.art/v1/generations/{id}/status \ -H "Authorization: Bearer $IMAGINE_API_KEY"
{ "status": "success", "data": { "id": "9e9f558c-4b4e-40fd-b67e-8617906c2cd1", "status": "completed", "images": [{ "url": "https://cdn.imagine.art/..." }] } }
Every request except GET /models and GET /cost needs your key as a Bearer token. Those two work without one, but list only public models; send your key to also see models granted to your organization.
Authorization: Bearer $IMAGINE_API_KEY
A key belongs to one organization and spends its credits. The secret is shown once, when you create it; after that only a short preview is visible.
Give each key a credit cap that resets on a schedule, so one integration can’t drain the balance. A request past the cap fails with 402, code 1210.
curl -X POST https://api.imagine.art/v1/keys \ -H "Authorization: Bearer $IMAGINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Backend", "credit_limit": 50000, "credit_limit_period": "monthly" }'
The secret is in data.key. Use GET /keys to list, PATCH /keys/{id} to rename or change the limit, and DELETE /keys/{id} to revoke.
Pass the model ID as model in the generate request. Each model’s page has its full input schema and an llms.txt for agents.
GET /models returns each model’s inputs: type, whether it’s required, length limits and allowed values. Page with limit and cursor. The list depends on the key: some models are open only to organizations granted them, and an invalid key gets 401.
{ "id": "imagineart-1.5", "type": "image", "inputs": [ { "name": "prompt", "kind": "string", "required": true, "max_length": 2000 }, { "name": "aspect_ratio", "kind": "enum", "values": ["1:1", "16:9", "9:16"] } ], "outputs": [{ "name": "images", "kind": "images" }] }
GET /cost returns each model’s base price and the factors that multiply it, such as aspect ratio or resolution. Send your key to include granted models; a base of 0 means the model is free.
Inputs like image_url, video_url and audio_url take a URL, not the file itself. It must be https, at most 2,048 characters, without credentials, on a public host (not localhost or a private IP), and stay valid until the generation completes. For a local file, upload it as an asset and pass its URL.
Upload images, videos and audio up to 100 MB to get a public URL you can pass to any URL input. An upload takes three requests: create it, send the bytes, then wait until it's processed. List them anytime with GET /assets/files.
curl -X POST https://api.imagine.art/v1/assets/files/uploads \ -H "Authorization: Bearer $IMAGINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "content_type": "image/png", "content_length": 482133 }'
{ "status": "success", "data": { "id": "6f1c2a9e-3d4b-4e8f-9a17-2b5c8d0e4f61", "type": "image", "upload_url": "https://….r2.cloudflarestorage.com/unprocessed/6f1c2a9e-3d4b-4e8f-9a17-2b5c8d0e4f61?X-Amz-…", "content_type": "image/png", "content_length": 482133 } }
PUT the raw bytes to upload_url within 5 minutes, with the same Content-Type and exactly content_length bytes. It's a signed storage URL, so don't send your API key with it.
curl -X PUT "$UPLOAD_URL" \ -H "Content-Type: image/png" \ --data-binary @photo.png
Poll every 2 seconds until data.status is finished, usually within 30 seconds. Then use https://asset.imagine.art/processed/{id} as the input URL. While a file is still processing the status can briefly answer 500; keep polling for up to a minute.
curl https://api.imagine.art/v1/assets/files/{id}/status \ -H "Authorization: Bearer $IMAGINE_API_KEY"
{ "status": "success", "data": { "id": "6f1c2a9e-3d4b-4e8f-9a17-2b5c8d0e4f61", "type": "image", "status": "finished", "metadata": { "type": "image", "mime_type": "image/png", "format_type": ".png", "file_size": 482133, "width": 1024, "height": 1024, "has_audio": false } } }
import mimetypes, os, time, requests API = "https://api.imagine.art/v1" headers = {"Authorization": f"Bearer {os.environ['IMAGINE_API_KEY']}"} path = "photo.png" content_type = mimetypes.guess_type(path)[0] # 1. Create the upload response = requests.post(f"{API}/assets/files/uploads", headers=headers, json={ "content_type": content_type, "content_length": os.path.getsize(path), }) response.raise_for_status() upload = response.json()["data"] # 2. Upload the bytes, with the same Content-Type with open(path, "rb") as file: requests.put( upload["upload_url"], data=file, headers={"Content-Type": content_type} ).raise_for_status() # 3. Wait until it's processed, usually 10 to 30 seconds for _ in range(30): time.sleep(2) response = requests.get(f"{API}/assets/files/{upload['id']}/status", headers=headers) response.raise_for_status() status = response.json()["data"]["status"] if status == "error": raise RuntimeError(f"Asset {upload['id']} could not be processed") if status == "finished": break else: raise TimeoutError("The asset is still processing after a minute") image_url = f"https://asset.imagine.art/processed/{upload['id']}"
import { readFile } from "node:fs/promises"; const API = "https://api.imagine.art/v1"; const headers = { Authorization: `Bearer ${process.env.IMAGINE_API_KEY}` }; const contentType = "image/png"; const file = await readFile("photo.png"); // 1. Create the upload const created = await fetch(`${API}/assets/files/uploads`, { method: "POST", headers: { ...headers, "Content-Type": "application/json" }, body: JSON.stringify({ content_type: contentType, content_length: file.byteLength }), }); if (!created.ok) throw new Error(await created.text()); const { data: upload } = await created.json(); // 2. Upload the bytes, with the same Content-Type const uploaded = await fetch(upload.upload_url, { method: "PUT", headers: { "Content-Type": contentType }, body: file, }); if (!uploaded.ok) throw new Error(await uploaded.text()); // 3. Wait until it's processed, usually 10 to 30 seconds let status = "pending"; for (let attempt = 0; attempt < 30 && status === "pending"; attempt += 1) { await new Promise((resolve) => setTimeout(resolve, 2000)); const response = await fetch(`${API}/assets/files/${upload.id}/status`, { headers }); if (!response.ok) throw new Error(await response.text()); ({ status } = (await response.json()).data); } if (status !== "finished") throw new Error(`Asset ${upload.id} is ${status}`); const imageUrl = `https://asset.imagine.art/processed/${upload.id}`;
GET /assets/files lists uploads, newest first; page with limit (1 to 100, default 20) and cursor. DELETE /assets/files/{id} removes an upload, and its URL stops working.
curl "https://api.imagine.art/v1/assets/files?limit=20" \ -H "Authorization: Bearer $IMAGINE_API_KEY"
{ "status": "success", "data": [ { "id": "6f1c2a9e-3d4b-4e8f-9a17-2b5c8d0e4f61", "type": "image", "created_at": "2026-11-23T05:16:53Z" } ], "pagination": { "limit": 20, "has_more": false, "next_cursor": null } }
curl -X DELETE https://api.imagine.art/v1/assets/files/{id} \ -H "Authorization: Bearer $IMAGINE_API_KEY"
{ "status": "success", "data": { "id": "6f1c2a9e-3d4b-4e8f-9a17-2b5c8d0e4f61", "deleted": true } }
A type that isn't image, video or audio, or a size over 100 MB, fails with 400, code 1100. An unknown id returns 404, code 1107.
{ "status": "error", "code": 1100, "error": "The sent request is invalid.", "message": "content_type must be an image, video or audio MIME type" }
POST /image/generate and POST /video/generate return 202 with a pending generation. Poll GET /generations/{id}/status until it ends.
The top-level status is about your HTTP request; data.status is the generation’s progress.
Poll every 3 seconds for images and 5 for video, and stop after about 10 minutes. Polls count toward the rate limit; on 429, wait Retry-After seconds.
import os, time, requests API = "https://api.imagine.art/v1" headers = {"Authorization": f"Bearer {os.environ['IMAGINE_API_KEY']}"} generation = requests.post(f"{API}/image/generate", headers=headers, json={ "model": "imagineart-2.0", "input": {"prompt": "A red convertible above Cinque Terre"}, }).json()["data"] while generation["status"] not in ("completed", "failed"): time.sleep(3) response = requests.get(f"{API}/generations/{generation['id']}/status", headers=headers) if response.status_code == 429: time.sleep(int(response.headers.get("Retry-After", 3))) continue generation = response.json()["data"] print(generation["images"])
GET /generations lists past generations, newest first. Filter by model or status; page with limit and cursor. Output URLs are signed and valid for 166 hours, so download the outputs you want to keep. A generation that fails upstream is retried up to 3 times under the same id and charged once.
Apps are multi-step pipelines built by creators on ImagineArt. You run an App with one request and poll it like a generation. Browse them under Apps.
GET /flow/app/ lists public Apps; add scope=mine for your own. GET /flow/app/{id} returns one App by its id.
{ "id": "app_8c1f...", "name": "Product shot to ad", "base_cost": 2916, "monetization": "low", "inputs": [ { "id": "in_1", "handle": "imageUrl", "node_id": "n_3", "node_type": "ImageUpload" } ] }
Send each input back with a value.
curl -X POST https://api.imagine.art/v1/flow/app/run \ -H "Authorization: Bearer $IMAGINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "app_id": "app_8c1f...", "execution_count": 1, "inputs": [ { "id": "in_1", "handle": "imageUrl", "node_id": "n_3", "node_type": "ImageUpload", "value": "https://example.com/bottle.png" } ] }'
GET /flow/app/{task_id}/status returns the run’s status and outputs. A finished output’s URL is at outputs[].content.<type>.content. GET /flow/app/{app_id}/results lists past runs.
POST /flow/app creates an App from a workflow graph in one request. Send the graph’s nodes and edges (the shape GET /flow/app/{id}/graph returns), the inputs people fill in and a parameters entry for each. inputs, parameters, input_presets and base_cost are required, even if empty. Apps you create can be deleted with DELETE /flow/app/{id} but not edited yet.
curl -X POST https://api.imagine.art/v1/flow/app \ -H "Authorization: Bearer $IMAGINE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "name": "Photo Upscaler", "slug": "photo-upscaler-a1b2c3", "description": "Upscales a photo 2x.", "graph": { "nodes": [{ "id": "n1", "type": "upscale-image", "data": { … } }], "edges": [] }, "inputs": [ { "id": "in1", "name": "", "description": "", "handle": "imageUrl", "node_id": "n1", "node_type": "upscale-image" } ], "parameters": [ { "id": "in1", "type": "image", "label": "Photo", "required": true, "order": 0, "default": "", "options": [], "limit": 1, "version": 2 } ], "input_presets": [], "base_cost": 20 }'
A run costs base_cost plus the creator fee for the App’s monetization tier.
You pay when a generation is accepted. Invalid requests are free, and generations that fail are refunded. The API counts in credits, and one credit is $0.003. Every usage endpoint takes range: today, 24h, 7d or 30d.
GET /logs has one row per request: status, HTTP code, credits, closing balance, key and model. GET /audit-logs records account actions such as creating or revoking a key. Both page with limit and cursor.
Errors return status: "error", a numeric code and a readable message.
{ "status": "error", "code": 1000, "message": "The bearer token is missing from the header." }
A generation that fails after it starts isn’t an HTTP error: it ends with data.status = failed.
Status polls are GET requests, so they count toward the GET limit. Past the limit you get 429 with a Retry-After header. Need more? Contact sales and we’ll raise it for your organization.
Paths are relative to https://api.imagine.art/v1.