GPT Image 2 (Subscription)

POSThttps://sangtao.ai/api/v2/agents/jobs/create

Generate images with GPT Image 2 on your subscription — from 100₫ an image, with up to 20 reference images per request.

Asynchronous: create a job, poll until it finishes, then read the result URL. A job usually takes 30–90 seconds.

Headers

X-Api-Keystringrequired

Your API key. Create one on the API Key page in your account.

Content-Typestringrequired

application/json

Request

One job usually produces one image — occasionally two. For a predictable number, create one job each.

modelstringrequired

Must be "chatgpt-image-sangtao"

promptstringrequired

What to draw. Describe the scene, the style and the composition — one or two words is not enough. A short prompt like "blue square" comes back as PROMPT_UNCLEAR.

aspectRatiostringoptional

"1:1", "16:9", "9:16"… Describing the shape inside the prompt works too, so this field is a convenience rather than the only way.

formatstringoptionaldefault "png"

"png" or "jpeg"

referenceImagesstring[]optional

Up to 20 links, each starting with http:// or https://. Every one must open without a login — we fetch them while creating the job and refuse it outright rather than letting the job run and fail later. Some CDNs block requests coming from another server, so a link that works in your browser can still be rejected. If the image only exists on your machine, upload it first: Image upload returns a URL you can use here.

resolutionstringoptionaldefault "1K"

"1K" or "2K". 2K gives a long edge of about 2048px

requireTransparentbooloptional

Ask for a transparent background

dpiintoptional

1–1200. Print metadata only — does NOT change pixel size

idempotencyKeystringoptional

Protects a retry from creating a second job: calling again with the same key returns the same jobId, with nothing charged twice. Use a NEW value for every job you actually want — only the key is compared, not the prompt, so a reused one hands back the earlier image with no error. It holds for about five minutes. A UUID per job, or your own order id.

Response

jobIdstring

The job id. Pass it to GET /jobs/{jobId} to poll for the result. Store it against your own order or record — it is the only handle you have on the job afterwards.

statusstring

Always "WaitingForAgent" here — the job is queued, not running yet.

chargeSourcestring

"Subscription" when a monthly plan covers it, "Credit" when it is paid from your balance.

creditCostnumber

What this job cost. 0 when a plan covered it.

quotaRemainingnumber

Plan allowance left after this job. null when credits paid.

queuePositionnumber

Place in the queue. 0 means it starts immediately.

queueDepthnumber

How many jobs the queue holds in total.

runningJobsnumber

Your jobs running right now.

concurrencynumber

How many of your jobs may run at once. Extra jobs queue rather than fail.

capReasonstring

Why that concurrency figure — e.g. your plan, or machine capacity.

runningOnFallbackbool

Whether a backup machine pool took the job. null in the normal case.

Errors while running

A failed job comes back with status "error" and a failureKind. This is the field that decides whether retrying is worth anything — retrying a permanent failure only burns more money.

failureKindMeaningRetry?
PROMPT_UNCLEARDescription too vagueNo — change the prompt
CONTENT_REJECTEDAgainst the content policyNo — change the prompt
TRANSPARENT_CREATION_FAILEDTransparency asked for, image came back without alphaNo — be more explicit in the prompt
REFERENCE_DOWNLOAD_FAILEDCould not fetch a reference imageNo — fix the link
GENERATION_TIMEOUTRan out of timeYes — usually works
QUOTA_EXHAUSTEDTemporarily at capacityYes — after a few hours
SESSION_EXPIREDA problem on our side, not with your requestContact support
INVALID_PAYLOADA problem on our sideContact support
POST/agents/jobs/create
curl -X POST \
  https://sangtao.ai/api/v2/agents/jobs/create \
  -H "X-Api-Key: YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "chatgpt-image-sangtao",
    "prompt": "A vintage travel poster of Ha Long Bay at sunset",
    "aspectRatio": "9:16",
    "resolution": "2K"
  }'
{
  "success": true,
  "data": {
    "jobId": "acff47cbfacf4e27bbc08770c9ea246d",
    "status": "WaitingForAgent",
    "chargeSource": "Subscription",
    "creditCost": 0.0,
    "quotaRemaining": 966,
    "queuePosition": 0,
    "queueDepth": 50,
    "runningJobs": 0,
    "concurrency": 10,
    "capReason": "gói thuê bao",
    "runningOnFallback": null
  },
  "error": null,
  "errorCode": null
}