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
| Field | Type | Description |
|---|---|---|
| prompt | string | Required. The image generation prompt. |
| image_count | number | Optional, defaults to 1. Number of images to generate. |
| size | string | Optional, for example 1024x1024. |
| quality | string | Optional: low, medium, high. |
| output_format | string | Optional, usually png. |
Output fields
| Field | Type | Description |
|---|---|---|
| task.id | string | Task ID. Put it into `{task_id}` when polling. |
| task.status | string | queued, running, succeeded, failed, canceled. |
| task.output_urls | string[] | Generated image download URLs. Empty before completion. |
| task.output_image_count | number | Number of images successfully generated. |
| task.error | string | Failure reason. Check this when the task fails. |
| quota.image_remaining | number | Remaining total image quota for the API key. |
| quota.daily_remaining | number | Remaining daily image quota for the API key. |
Other endpoints
| POST | /v1/tasks | Create one generation task. |
| GET | /v1/tasks/{task_id} | Get one task status and output. |
| GET | /v1/tasks?status=all&page=1&limit=20 | List tasks for the current API key. |
| GET | /v1/quota | Check quota for the current API key. |
| POST | /v1/batches | Create 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.