AI Video
POST
https://sangtao.ai/api/v2/videos/generateReference for AI Video.
Generate AI videos from text prompts or images. Supports text-to-video and image-to-video modes. Returns a jobId for polling.
Request Body
| Field | Type | Description |
|---|---|---|
| model* | string | Model slug from GET /api/v2/models?category=Video |
| prompt* | string | Text description of the video to generate |
| imageId | string | Source image job ID for image-to-video (from a completed image generation job) |
| imageIds | string[] | Multiple source image job IDs (for models supporting multi-image input) |
| duration | int | Video duration in seconds. Depends on model (5 or 10s typically) |
| resolution | string | Output resolution: "720p", "1080p". Default varies by model |
| aspectRatio | string | "16:9" | "9:16" | "1:1". Default: "16:9" |
| mode | string | Generation mode (model-specific). E.g. "standard", "pro" |
| modeImage | string | Image processing mode for image-to-video. Model-specific option |
Tip: Use GET /api/v2/models?category=Video to list available video models and their supported options.
cURL
bash
curl -X POST https://sangtao.ai/api/v2/videos/generate \
-H "X-Api-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-fast",
"prompt": "A drone shot flying over rice terraces in Sapa, golden hour lighting",
"aspectRatio": "16:9",
"duration": 5
}'Text-to-Video Example
Generate a video from a text prompt only:
json
{
"model": "veo-3.1-fast",
"prompt": "A drone shot flying over rice terraces in Sapa, golden hour lighting",
"aspectRatio": "16:9",
"duration": 5
}Image-to-Video Example
Animate a generated image into a video. First generate an image, then use its jobId as imageId:
json
{
"model": "veo-3.1-fast",
"prompt": "Camera slowly zooms in, gentle wind blowing",
"imageId": "img-abc123",
"duration": 5
}Response
json
{
"success": true,
"data": {
"jobId": "vid-xyz789"
}
}Job Polling
Poll GET /api/v2/jobs/{jobId} every 5 seconds. Video generation typically takes 30s-3min.
json
// GET /api/v2/jobs/{jobId}
{
"success": true,
"data": {
"status": "complete",
"resultUrl": "https://cdn.sangtao.ai/videos/result.mp4",
"thumbnailUrl": "https://cdn.sangtao.ai/videos/thumb.jpg"
}
}Credit Flow
| Phase | Description |
|---|---|
| Lock | Credits are estimated and locked when you submit the job |
| Calculate | After processing, actual cost is calculated based on scenes and voice usage |
| Settle | When complete, excess credits are automatically refunded |
Note:
lockedCreditCost in the response is a high estimate. Actual cost is usually lower.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 |