AI GPT ImageAI GPT Image

Query Task

Use this endpoint to poll a task until it reaches success or fail.

Endpoint

GET /api/v1/jobs/recordInfo?taskId=task_xxx

Headers

Authorization: Bearer sk-your-api-key

Example

curl "https://aigptimage.com/api/v1/jobs/recordInfo?taskId=task_xxx" \
  -H "Authorization: Bearer sk-your-api-key"

Example responses

When the task is still running:

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "5064bd1a-025a-490b-b28f-6a9fa12eb88a",
    "model": "gpt-image-2-text-to-image",
    "state": "waiting",
    "param": "{\"model\":\"gpt-image-2-text-to-image\",\"input\":{\"prompt\":\"A cinematic portrait of a robot painter\"}}",
    "resultJson": null,
    "failCode": null,
    "failMsg": null,
    "costTime": null,
    "completeTime": null,
    "createTime": 1777474689024
  }
}

When the task succeeds:

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_xxx",
    "model": "gpt-image-2-text-to-image",
    "state": "success",
    "param": "{\"model\":\"gpt-image-2-text-to-image\",\"input\":{\"prompt\":\"A cat\"}}",
    "resultJson": "{\"resultUrls\":[\"https://cdn.example.com/result.png\"]}",
    "failCode": null,
    "failMsg": null,
    "costTime": 32241,
    "completeTime": 1777460000000,
    "createTime": 1777459967759
  }
}

When the task fails:

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "5f6ff8ea-ae97-4bb8-af5e-752ef4e96c0d",
    "model": "gpt-image-2-text-to-image",
    "state": "fail",
    "param": "{\"model\":\"gpt-image-2-text-to-image\",\"input\":{\"prompt\":\"360 equirectangular panorama, first-person view standing on stage at a massive concert with Michael Jackson performing, huge crowd cheering with hands raised, bright stage lights, smoke, dramatic spotlight, ultra realistic, cinematic concert atmosphere, immersive perspective, high detail, 2:1 aspect ratio, 4096x2048, no distortion\"}}",
    "resultJson": null,
    "failCode": "400",
    "failMsg": "Sorry, but the image we created may violate OpenAI's content policies.",
    "costTime": null,
    "completeTime": null,
    "createTime": 1777475010433
  }
}

States

StateMeaning
waitingThe task is pending or processing
successThe task completed successfully
failThe task failed or was canceled

Response fields

FieldTypeDescription
data.taskIdstringTask ID
data.modelstringPublic model ID
data.statestringTask status: waiting, success, fail
data.paramstringOriginal create task request parameters as a JSON string
data.resultJsonstring | nullResult JSON string. Usually contains resultUrls when successful
data.failCodestring | nullFailure code when the task fails
data.failMsgstring | nullFailure message when the task fails
data.costTimeinteger | nullTask duration in milliseconds after completion
data.completeTimeinteger | nullCompletion timestamp in milliseconds
data.createTimeintegerCreation timestamp in milliseconds

Result format

When state is success, resultJson is a JSON string:

{
  "resultUrls": ["https://cdn.example.com/result.png"]
}

When state is fail, check:

  • failCode: platform error code returned for the failed task
  • failMsg: human-readable failure reason

The HTTP request itself can still return 200 while the task state is fail. The final task result must be determined from data.state.