Create image task
POST/v1/images/tasks
Submit image generation or editing as an asynchronous task; HTTP 202 with a task_id is returned immediately. Then use Retrieve task for progress and List task artifacts for the images.
Submission only checks the basic format; generation parameters are validated when the task runs. Failures set the task to FAILURE with the reason in fail_reason. Charging also happens at run time, and failures follow the server refund flow.
Headers
AuthorizationstringRequiredBearer <API_KEY>.Content-TypestringRequiredapplication/json. Only JSON bodies are supported.Idempotency-KeystringRequiredUp to 256 bytes; use a new value (such as a UUID) per new task. If the outcome is unclear, retry with the same API key, body and key to get the original
task_idwithout generating again. Never reuse a key for a different body.
Request bodyJSON
See the corresponding synchronous endpoint for basic parameters. For GPT Image tasks, use the compatible fields listed there and omit extensions such as quality, background, output format, compression and moderation.
- GPT Image · Create imageText to image
- GPT Image · Edit imageReference editing,
operation: "edits" - Seedream · Create imageText and reference generation
operationstringOptionalHow to run the task. When omitted:
editsfor GPT Image withimages, otherwisegenerations.Supported values
generationsText-to-image; Seedream references go inimageeditsGPT Image only; references go inimages
streambooleanOptionalDefaultfalseTasks return no streaming response. Omit
stream. The whole body must not exceed 4 MiB.
Returns
HTTP 202, task accepted. Poll GET /v1/tasks/{task_id}, then fetch images from GET /v1/tasks/{task_id}/artifacts once it is SUCCESS.
task_idstringOptionalTask ID for status and artifacts.
Errors
Errors return {"error": {"message": "...", "type": "...", "code": "..."}}.
| HTTP | code | Cause and action |
|---|---|---|
| 400 | invalid_image_task | Model, prompt, operation, reference fields or stream do not follow this page. |
| 400 | invalid_idempotency_key | Missing Idempotency-Key or longer than 256 bytes. |
| 403 | access_denied | The key does not allow this model. |
| 409 | idempotency_conflict | The key was used with a different body. |
| 413 | image_task_request_too_large | Body larger than 4 MiB. |
| 415 | image_task_json_required | Content-Type is not application/json. |
| 503 | image_task_storage_unavailable / image_task_queue_unavailable | Result storage or the queue is unavailable; retry later with the same key. |
curl -X POST https://ling-light.com/v1/images/tasks \
-H "Authorization: Bearer $LINGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "gpt-image-2.6",
"prompt": "A cat in a garden",
"size": "1024x1024"
}'const response = await fetch('https://ling-light.com/v1/images/tasks', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"model": "gpt-image-2.6",
"prompt": "A cat in a garden",
"size": "1024x1024"
}),
})
console.log(response.status, await response.json())import os
import uuid
import requests
response = requests.post(
"https://ling-light.com/v1/images/tasks",
headers={
"Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"model": "gpt-image-2.6",
"prompt": "A cat in a garden",
"size": "1024x1024",
},
timeout=60,
)
print(response.status_code, response.json()){
"task_id": "task_xxxxxxxxxxxxxxxx"
}curl -X POST https://ling-light.com/v1/images/tasks \
-H "Authorization: Bearer $LINGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "gpt-image-2.6",
"operation": "edits",
"prompt": "Keep the subject and turn it into a night scene",
"images": [
{
"image_url": "asset://a1B2c3D4e5F6"
}
],
"size": "1024x1536"
}'const response = await fetch('https://ling-light.com/v1/images/tasks', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"model": "gpt-image-2.6",
"operation": "edits",
"prompt": "Keep the subject and turn it into a night scene",
"images": [
{
"image_url": "asset://a1B2c3D4e5F6"
}
],
"size": "1024x1536"
}),
})
console.log(response.status, await response.json())import os
import uuid
import requests
response = requests.post(
"https://ling-light.com/v1/images/tasks",
headers={
"Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"model": "gpt-image-2.6",
"operation": "edits",
"prompt": "Keep the subject and turn it into a night scene",
"images": [
{
"image_url": "asset://a1B2c3D4e5F6",
},
],
"size": "1024x1536",
},
timeout=60,
)
print(response.status_code, response.json()){
"task_id": "task_xxxxxxxxxxxxxxxx"
}curl -X POST https://ling-light.com/v1/images/tasks \
-H "Authorization: Bearer $LINGLIGHT_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"model": "seedream-5.0-pro",
"prompt": "Keep the subject and switch to a snowy background",
"image": "asset://a1B2c3D4e5F6",
"size": "2K"
}'const response = await fetch('https://ling-light.com/v1/images/tasks', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.LINGLIGHT_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': crypto.randomUUID(),
},
body: JSON.stringify({
"model": "seedream-5.0-pro",
"prompt": "Keep the subject and switch to a snowy background",
"image": "asset://a1B2c3D4e5F6",
"size": "2K"
}),
})
console.log(response.status, await response.json())import os
import uuid
import requests
response = requests.post(
"https://ling-light.com/v1/images/tasks",
headers={
"Authorization": f"Bearer {os.environ['LINGLIGHT_API_KEY']}",
"Idempotency-Key": str(uuid.uuid4()),
},
json={
"model": "seedream-5.0-pro",
"prompt": "Keep the subject and switch to a snowy background",
"image": "asset://a1B2c3D4e5F6",
"size": "2K",
},
timeout=60,
)
print(response.status_code, response.json()){
"task_id": "task_xxxxxxxxxxxxxxxx"
}