API documentation

Call the image generation API in three steps.

Create a task, poll the task ID returned by the API, then read image download URLs from `output_urls`.

Base URL
https://api.imagen.chat
Authentication
Authorization: Bearer sk_img_xxx
Keep API keys on your server. Do not expose them in browser JavaScript.

Minimal flow

1

1. Create a task

Submit the prompt and generation settings. The response contains `task.id`.

curl -s https://api.imagen.chat/v1/tasks \
  -H "Authorization: Bearer sk_img_xxx" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A clean studio product image of a transparent glass perfume bottle",
    "image_count": 1,
    "size": "1024x1024",
    "quality": "medium",
    "output_format": "png"
  }'
Example response
{
  "task": {
    "id": "task_9f4a...",
    "status": "queued",
    "image_count": 1,
    "output_urls": []
  },
  "quota": {
    "image_remaining": 988,
    "daily_remaining": 96
  }
}
2

2. Poll the task

Replace `{task_id}` with the `task.id` returned by the create call, for example `task_9f4a...`.

curl -s https://api.imagen.chat/v1/tasks/{task_id} \
  -H "Authorization: Bearer sk_img_xxx"
3

3. Use the output URLs

When `task.status` becomes `succeeded`, read `task.output_urls`. Those are the generated image download links.

Successful response
{
  "task": {
    "id": "task_9f4a...",
    "status": "succeeded",
    "output_image_count": 1,
    "output_urls": [
      "https://cdn.example.com/generated/image.png"
    ],
    "error": ""
  }
}

Request fields

FieldTypeDescription
promptstringRequired. The image generation prompt.
image_countnumberOptional, defaults to 1. Number of images to generate.
sizestringOptional, for example 1024x1024.
qualitystringOptional: low, medium, high.
output_formatstringOptional, usually png.

Output fields

FieldTypeDescription
task.idstringTask ID. Put it into `{task_id}` when polling.
task.statusstringqueued, running, succeeded, failed, canceled.
task.output_urlsstring[]Generated image download URLs. Empty before completion.
task.output_image_countnumberNumber of images successfully generated.
task.errorstringFailure reason. Check this when the task fails.
quota.image_remainingnumberRemaining total image quota for the API key.
quota.daily_remainingnumberRemaining daily image quota for the API key.

Other endpoints

POST/v1/tasksCreate one generation task.
GET/v1/tasks/{task_id}Get one task status and output.
GET/v1/tasks?status=all&page=1&limit=20List tasks for the current API key.
GET/v1/quotaCheck quota for the current API key.
POST/v1/batchesCreate a batch with a `tasks` array.

Status and errors

`queued` means waiting, `running` means generating, `succeeded` means complete, `failed` means failed, and `canceled` means canceled.

Errors return JSON: `{"error":"..."}`. Common statuses: 400 invalid request, 401 invalid key, 404 task not found, 429/503 quota or capacity unavailable.