AI Image
POST
https://sangtao.ai/api/v2/images/generateReference for AI Image.
Generate AI images from a text prompt. Returns a jobId — poll GET /api/v2/jobs/{jobId} for results.
Request Body
| Field | Type | Description |
|---|---|---|
| model* | string | Model slug from GET /api/v2/models?category=Image |
| prompt* | string | Text description of the image to generate |
| numImages | int | Number of images to generate (1-4). Default: 1 |
| size | string | Image size. Depends on model, e.g. "1024x1024" |
| refImageUrls | string[] | Reference image URLs for visual consistency. Upload first via POST /api/v2/images/upload |
| tier | string | Generation tier: "standard" (default, 1x credit) or "vip1" (higher quality, 5x credit). Affects routing and quality |
| options | object | Per-model options. Keys from GET /api/v2/models/{slug} config. E.g. aspectRatio, outputFormat, resolution, style |
Tip: Use GET /api/v2/models?category=Image to list all available image models and their config options.
cURL
bash
curl -X POST https://sangtao.ai/api/v2/images/generate \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-pro",
"prompt": "A cozy Vietnamese coffee shop in Hanoi Old Quarter, morning light",
"numImages": 2,
"options": { "aspectRatio": "16:9" }
}'JSON Body
json
{
"model": "nano-banana-pro",
"prompt": "A cozy Vietnamese coffee shop in Hanoi Old Quarter, morning light",
"numImages": 2,
"options": {
"aspectRatio": "16:9",
"outputFormat": "jpeg",
"resolution": "1K"
}
}Response
Returns a jobId. Poll the job status endpoint to get results:
json
{
"success": true,
"data": {
"jobId": "img-abc123"
}
}Job Polling
Poll GET /api/v2/jobs/{jobId} every 3 seconds until status is "complete" or "error".
json
// GET /api/v2/jobs/{jobId}
{
"success": true,
"data": {
"status": "complete",
"resultImages": [
"https://cdn.sangtao.ai/images/result1.jpg",
"https://cdn.sangtao.ai/images/result2.jpg"
]
}
}Note: Image results are in the resultImages array. Each URL is a direct link to the generated image.
Error Codes
| Code | When |
|---|---|
| 400 | Invalid input (story too short/long, model/voice not found...) |
| 401 | Unauthorized — missing or invalid API key / token |
| 402 | Insufficient credits or premium voice requires top-up |
| 429 | Already 4 jobs running concurrently |
| 503 | System is processing too many requests. Please retry after 30 seconds |