AI Video

POSThttps://sangtao.ai/api/v2/videos/generate

Reference 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

FieldTypeDescription
model*stringModel slug from GET /api/v2/models?category=Video
prompt*stringText description of the video to generate
imageIdstringSource image job ID for image-to-video (from a completed image generation job)
imageIdsstring[]Multiple source image job IDs (for models supporting multi-image input)
durationintVideo duration in seconds. Depends on model (5 or 10s typically)
resolutionstringOutput resolution: "720p", "1080p". Default varies by model
aspectRatiostring"16:9" | "9:16" | "1:1". Default: "16:9"
modestringGeneration mode (model-specific). E.g. "standard", "pro"
modeImagestringImage 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

PhaseDescription
LockCredits are estimated and locked when you submit the job
CalculateAfter processing, actual cost is calculated based on scenes and voice usage
SettleWhen complete, excess credits are automatically refunded
Note: lockedCreditCost in the response is a high estimate. Actual cost is usually lower.

Error Codes

CodeWhen
400Invalid input (story too short/long, model/voice not found...)
401Unauthorized — missing or invalid API key / token
402Insufficient credits or premium voice requires top-up
429Already 4 jobs running concurrently
503System is processing too many requests. Please retry after 30 seconds