AI GPT ImageAI GPT Image

Create Task

Create a generation task. A successful response only means the task was accepted; it does not mean generation is complete.

Endpoint

POST /api/v1/jobs/createTask

Headers

Authorization: Bearer sk-your-api-key
Content-Type: application/json
X-Request-ID: xxxxxxxxxxxx

Header Parameters

HeaderRequiredHow to set itDescription
AuthorizationYesBearer sk-your-api-keyYour API key. Create it on the API Keys page.
Content-TypeYesapplication/jsonRequired because the request body must be JSON.
X-Request-IDNo, but strongly recommendedA UUID or your own backend request IDIdempotency header for createTask. If the same API key sends the same request ID again, the API can return the existing task instead of creating a duplicate task.

About X-Request-ID

X-Request-ID is optional. If you do not send it, the request can still succeed and the API will still create a task normally.

You should still send it for production use, especially when your backend may retry requests because of:

  • network timeouts
  • client retries
  • queue workers retrying failed jobs
  • users clicking the same action multiple times

Recommended ways to generate it:

  • a value such as xxxxxxxxxxxx
  • your own business request ID, such as order-20260429-000123
  • your internal job ID, such as image-task-user123-456

Best practice:

  • generate X-Request-ID on your own backend
  • keep it stable when retrying the same logical request
  • generate a new value for a new logical request

Body

FieldTypeRequiredDescription
modelstringYesPublic model ID
inputobjectYesModel input parameters

Example

curl -X POST "https://aigptimage.com/api/v1/jobs/createTask" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -H "X-Request-ID: xxxxxxxxxxxx" \
  -d '{
    "model": "gpt-image-2-text-to-image",
    "input": {
      "prompt": "A clean product photo of a translucent glass speaker",
      "aspect_ratio": "1:1",
      "resolution": "1K"
    }
  }'

Response

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_xxx"
  }
}

Credit behavior

Credits are consumed using the same pricing logic as the web app. The credit deduction path is protected against concurrent overuse.