REST API
API reference
One key, nine endpoints. Generate and edit images, render video and lip sync, cut and replace backgrounds, read images back as text, and manage the brand assets your generations reuse.
Overview
Every endpoint lives under one base URL, speaks JSON, and is authenticated with the same API key.
https://app.apimage.org/api/v1/{endpoint}| Endpoint | Does | Credits |
|---|---|---|
/image-studio | Generate & edit images (FLUX 2, GPT Image 2) | 1–9 |
/ai-image-generate | OpenAI image models (GPT Image 2, DALL·E 3) | 1–9 |
/ai-video-generate | Seedance 2.0 video and lip sync | metered |
/generations | Status and history for images and videos | free |
/ai-remove-background | Transparent cutout | 2 |
/ai-replace-background | Replace and relight the scene | 3 |
/ai-image-to-text | Describe, OCR or answer questions | 1 |
/brand-assets | Characters, products, backgrounds, palettes | free |
/usage | Credit balance, quota and plan | free |
Prefer to skip the plumbing?
Authentication
Send your API key as a bearer token on every request. Generate one under Dashboard → API keys.
Authorization: Bearer sk_your_api_keysk_…API keyThe current format. Scoped to the workspace the key was created in, which is where credits are drawn from.
apimg_…legacy keyStill accepted, but responses carry a warning field. Rotate to an sk_ key.
eyJ…Supabase JWTA signed-in user session, used by the dashboard itself. Pass x-workspace-id to target a specific workspace.
Do not ship keys to the browser
?api_key= query parameter is still honoured for legacy integrations, but it leaks through logs and referrers. Call the API from your server.Credits & pricing
Credits are reserved before a job starts and settled when it finishes. Failed generations are refunded automatically, so a provider outage never costs you anything.
| Model | HD | Full HD | 4K |
|---|---|---|---|
| flux-2-klein-9b | 1 | 1 | 2 |
| flux-2-pro | 1 | 2 | 4 |
| flux-2-max | 3 | 4 | 9 |
| gpt-image-2 | 3 | 4 | 9 |
Reference images add a surcharge based on their megapixel count — doubled on flux-2-max and gpt-image-2, which bill input tokens at the premium rate. Video is metered per token and returns its exact cost in the response.
Check before you spend
GET /usage is free and returns the live balance. Call it once at boot rather than catching 402 in a retry loop.Image Studio
The main image endpoint. One route covers generation, six edit tools, prompt enhancement and status polling, selected by the action field.
https://app.apimage.org/api/v1/image-studioaction: generate
1–9 creditsThe default when action is omitted. Pass reference images to condition the result on existing artwork, a product shot or a character.
promptstringrequiredWhat to generate.
modelstringflux-2-pro (default), flux-2-klein-9b, flux-2-max or gpt-image-2.
aspect_ratiostring1:1, 16:9, 9:16, 4:3, 3:4, 21:9 or 9:21. Defaults to 1:1.
resolutionstringSD, HD, Full HD or 4K. Defaults to HD and drives the credit cost.
input_imagesstring[]Up to 4 reference images as URLs or base64. Adds a megapixel surcharge.
width / heightnumberExplicit pixel size, used only when aspect_ratio is absent.
seednumberFix for reproducible output.
safety_tolerancenumberProvider moderation threshold. Defaults to 2.
visibilitystringpublic or private. Public results can surface in the inspiration feed.
curl -X POST https://app.apimage.org/api/v1/image-studio \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cyberpunk city with flying cars and neon signs",
"model": "flux-2-pro",
"aspect_ratio": "16:9",
"resolution": "Full HD"
}'{
"id": "8f3c1e02-4b6a-4c19-9d21-7a0f5be1c8d4",
"status": "completed",
"image_url": "https://cdn.apimage.org/...",
"message": "Generation complete"
}Slow jobs return pending
status: "pending" with the generation id. Poll it with action: "check_status" or GET /generations — the reservation is settled or refunded either way.action: edit
priced as a generationsource_imagestringrequiredURL or base64 of the image to transform.
edit_toolstringrequiredenhance, relight, color_grade, angle, upscale or inpaint.
tool_optionstringPreset for the chosen tool — a lighting style ("golden hour"), a grade ("cinematic") or a camera angle ("low angle").
promptstringExtra instructions. Required in practice for inpaint.
mask_imagestringBase64 mask for inpaint. White marks the editable region.
{
"action": "edit",
"edit_tool": "relight",
"tool_option": "golden hour",
"source_image": "https://cdn.apimage.org/your-image.png"
}action: enhance_prompt
freeRewrites a thin prompt into a detailed one. Costs nothing, so run it on user input before spending credits on the generation.
// POST
{ "action": "enhance_prompt", "prompt": "a dog on a beach" }
// 200
{
"enhanced_prompt": "A golden retriever mid-stride across wet sand at low tide...",
"original_prompt": "a dog on a beach"
}action: check_status
freePolls the provider for up to 60 seconds and finalises a pending generation — storing the result on success, refunding the reserved credits on failure.
{ "action": "check_status", "generation_id": "8f3c1e02-4b6a-4c19-9d21-7a0f5be1c8d4" }Background removal auto-routing
2 credits + inputSend an input_images entry with a prompt like "remove the background" and the router hands the job to the dedicated cutout engine instead of FLUX. Call /ai-remove-background directly when you want that behaviour guaranteed.
OpenAI images
A separate route for OpenAI's models. Reach for it when you need DALL·E 3, batches of up to four images per call, or the preset system.
https://app.apimage.org/api/v1/ai-image-generatepromptstringrequiredRequired unless a preset is supplied.
modelstringgpt-image-2 (default) or dall-e-3. Older ids such as gpt-image-1 resolve to gpt-image-2.
num_imagesnumber1–4. Cost multiplies accordingly.
aspect_ratio + resolutionstringPreferred sizing interface for gpt-image-2.
width / heightnumber256–1792. Snapped to a valid size for gpt-image-2.
qualitystringauto, low, medium, standard or high. DALL·E 3 at high quality costs 2 credits.
negative_promptstringWhat to keep out of the frame.
seednumberReproducibility.
webhook_urlstringSwitches the call to async: returns immediately with a pending id and calls you back.
{
"success": true,
"data": {
"id": "2b91...",
"status": "completed",
"images": ["https://cdn.apimage.org/..."],
"cost": 3
}
}Video & lip sync
Seedance 2.0 in four modes. Always asynchronous — the call returns an id and the exact credit cost, then you poll or take a webhook.
https://app.apimage.org/api/v1/ai-video-generatePaid plans only
403 Upgrade required on the free tier, and each account is capped at a small number of in-flight jobs.modestringtext-to-video (default), image-to-video, video-to-video or lip-sync.
promptstringRequired for text-to-video, recommended everywhere else.
modelstringseedance-2-0 (default, up to 1080p) or seedance-2-0-fast (cheaper, up to 720p).
resolutionstring480p, 720p (default) or 1080p.
ratiostring16:9 (default), 9:16, 1:1, 4:3, 3:4 or 21:9.
durationnumberOutput length in seconds, 4–15. Ignored for lip sync, which follows the audio.
reference_imagesstring[]Up to 4 image URLs — brand characters or products to carry into the shot.
seednumberReproducibility.
visibilitystringpublic or private. Falls back to your account default.
webhook_urlstringCalled on completion or failure.
input_image_urlstringFirst frame for image-to-video. The avatar image for lip-sync.
input_image_url_laststringOptional last frame for image-to-video.
input_video_urlstringReference clip for video-to-video.
input_video_lengthnumberLength of that clip in seconds, 1–60. Required for video-to-video.
input_audio_urlstringSpeech track for lip-sync.
input_audio_lengthnumberAudio length in seconds, 1–30. Sets the output duration for lip-sync.
curl -X POST https://app.apimage.org/api/v1/ai-video-generate \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"mode": "text-to-video",
"prompt": "Slow dolly across a rain-soaked Tokyo alley at night",
"resolution": "1080p",
"ratio": "16:9",
"duration": 8
}'Generations
Read-only status and history for everything you have created. Free, and the endpoint you poll while a video renders.
https://app.apimage.org/api/v1/generationstypestringrequiredimage or video.
iduuidReturn one generation instead of a page.
statusstringpending, processing, completed or failed.
modestringVideo only. Filters by generation mode, including lip-sync.
limitnumber1–100. Defaults to 20.
offsetnumberPagination offset. Defaults to 0.
curl "https://app.apimage.org/api/v1/generations?type=video&id=c41d7f8a-9e2b-4f60-8a13-5d9c02b7e114" \
-H "Authorization: Bearer sk_your_api_key"Background tools
Two dedicated routes for the operations that carry a product shot: cut the subject out, or drop it into a new scene with matching light.
Remove background
2 creditshttps://app.apimage.org/api/v1/ai-remove-backgroundimage_urlstringSource image. Required unless image_base64 is set.
image_base64stringInline alternative to image_url. The data-URI prefix is optional.
output_formatstringpng (default) or webp.
webhook_urlstringOptional completion callback.
{
"id": "6d20...",
"status": "completed",
"processed_image_url": "https://cdn.apimage.org/...",
"original_size": 842113,
"processed_size": 511204
}Replace background
3 creditshttps://app.apimage.org/api/v1/ai-replace-backgroundimage_urlstringrequiredThe subject image, or image_base64.
background_promptstringrequiredThe scene to place it in. A background_image_url can be supplied instead.
foreground_promptstringDescribes the subject, which sharpens the matte.
negative_promptstringWhat to keep out of the new scene.
light_source_directionstringabove, below, left or right.
preserve_original_subjectnumber0–1. Higher keeps the subject closer to the original. Defaults to 0.6.
seednumberReproducibility.
{
"id": "a0f4...",
"status": "completed",
"url": "https://cdn.apimage.org/...",
"format": "png",
"credits_used": 3,
"credits_remaining": 417
}Image to text
Vision in reverse: describe an image, pull the text out of it, or ask a question about what it shows.
https://app.apimage.org/api/v1/ai-image-to-texturlstringrequiredImage to analyse. A multipart file upload is also accepted.
promptstringWhat you want back — "Extract all text" or "Which products are shown?". Defaults to a detailed description.
webhook_urlstringOptional completion callback.
{
"id": "71ae...",
"status": "completed",
"description": "A matte-black espresso machine on a walnut counter...",
"tokens_used": 412,
"created_at": "2026-07-25T09:20:03.884Z"
}Brand assets
The reusable library behind consistent output: characters, products, backgrounds and colour presets. Full CRUD on one route, free to call.
https://app.apimage.org/api/v1/brand-assets?type=characterhttps://app.apimage.org/api/v1/brand-assetshttps://app.apimage.org/api/v1/brand-assetshttps://app.apimage.org/api/v1/brand-assets?type=product&id={uuid}typestringrequiredcharacter, product, background or color_preset. Required on every method.
iduuidTargets a single asset. Required for PATCH and DELETE.
namestringRequired when creating.
image_urlstringCharacters, products and backgrounds. Usually a generated image you are keeping.
sourcestringgenerated or uploaded.
categorystringGroups products, backgrounds and presets. Also filters GET.
attributesobjectFree-form traits — gender, age_range, hair_color, clothing_style, custom_details.
colorsstring[]Hex values. Required when creating a color_preset.
tagsstring[]Backgrounds and colour presets.
limit / offsetnumberPagination on GET. Limit defaults to 50, max 100.
curl -X POST https://app.apimage.org/api/v1/brand-assets \
-H "Authorization: Bearer sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"type": "character",
"name": "Mara, brand spokesperson",
"image_url": "https://cdn.apimage.org/generated/mara.png",
"source": "generated",
"attributes": { "age_range": "30-35", "clothing_style": "minimal workwear" }
}'Usage & credits
One free call for balance, quota and plan. Useful as a key-validity check on startup.
https://app.apimage.org/api/v1/usage{
"monthly_usage": 1284,
"monthly_limit": 5000,
"remaining": 3716,
"credits": 417,
"subscription_tier": "pro",
"email": "you@studio.com",
"name": "Your Name"
}Webhooks
Long jobs can call you instead of you polling them. Pass webhook_url on video, OpenAI image, background and analysis requests.
The callback is a POST carrying the same body the polling endpoint would have returned, plus a completion timestamp. Treat delivery as at-least-once and key your handler on the generation id.
{
"id": "c41d7f8a-9e2b-4f60-8a13-5d9c02b7e114",
"status": "completed",
"video_url": "https://cdn.apimage.org/...",
"cost_charged": 24,
"completed_at": "2026-07-25T09:18:11.402Z"
}Failures call back too
status: "failed" with an error message. The reserved credits are already back on your balance by then.Rate limits
Per-minute ceilings, returned on every response as X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset.
| Endpoint | Requests / min |
|---|---|
| /generations, /brand-assets | 120 |
| /ai-image-generate | 60 |
| /ai-video-generate | 30 |
| /ai-remove-background, /ai-replace-background | 30 |
Video also enforces a concurrency cap on in-flight jobs, which returns 429 with a message naming the limit. Back off and retry once a render finishes.
Errors
Every failure is JSON with an error label and a human-readable details string.
{
"error": "Insufficient credits",
"details": "This costs 24 credits, but you have 11.",
"status": 402
}400Bad request. A parameter is missing or outside its allowed range.
401Authentication failed. No key, or the key is malformed.
402Insufficient credits. Top up, or enable overage billing.
403Forbidden. Key not recognised, or the plan does not include this feature.
404Not found. The id does not exist, or belongs to another account.
429Rate limited. Too many requests, or too many videos in flight.
502Provider error. The upstream model failed. Credits were not charged.
500Internal error. Unexpected failure. Any reservation is rolled back.
Ready to make the first call?
Create a key in the dashboard, then start with GET /usage to confirm it works before spending a credit.