Skip to content

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.

Headers

  • AuthorizationstringRequired

    Bearer <API_KEY>.

  • Content-TypestringRequired

    application/json. Only JSON bodies are supported.

  • Idempotency-KeystringRequired

    Up 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_id without 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.

  • operationstringOptional

    How to run the task. When omitted: edits for GPT Image with images, otherwise generations.

    Supported values

    • generationsText-to-image; Seedream references go in image
    • editsGPT Image only; references go in images
  • streambooleanOptionalDefault false

    Tasks 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_idstringOptional

    Task ID for status and artifacts.

Errors

Errors return {"error": {"message": "...", "type": "...", "code": "..."}}.

HTTPcodeCause and action
400invalid_image_taskModel, prompt, operation, reference fields or stream do not follow this page.
400invalid_idempotency_keyMissing Idempotency-Key or longer than 256 bytes.
403access_deniedThe key does not allow this model.
409idempotency_conflictThe key was used with a different body.
413image_task_request_too_largeBody larger than 4 MiB.
415image_task_json_requiredContent-Type is not application/json.
503image_task_storage_unavailable / image_task_queue_unavailableResult storage or the queue is unavailable; retry later with the same key.
Submit a GPT Image generation task
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())
Response · HTTP 202
{
  "task_id": "task_xxxxxxxxxxxxxxxx"
}
Submit a GPT Image editing task
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())
Response · HTTP 202
{
  "task_id": "task_xxxxxxxxxxxxxxxx"
}
Submit a Seedream reference task
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())
Response · HTTP 202
{
  "task_id": "task_xxxxxxxxxxxxxxxx"
}
API reference overview
Authentication, media URLs, idempotency and errors.
Integration guide
The full flow from API key to downloaded result.
Last updated