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/createTaskHeaders
Authorization: Bearer sk-your-api-key
Content-Type: application/json
X-Request-ID: xxxxxxxxxxxxHeader Parameters
| Header | Required | How to set it | Description |
|---|---|---|---|
Authorization | Yes | Bearer sk-your-api-key | Your API key. Create it on the API Keys page. |
Content-Type | Yes | application/json | Required because the request body must be JSON. |
X-Request-ID | No, but strongly recommended | A UUID or your own backend request ID | Idempotency 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-IDon your own backend - keep it stable when retrying the same logical request
- generate a new value for a new logical request
Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Public model ID |
input | object | Yes | Model 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.