Video Generation

Generate videos from text or images asynchronously -- submit a prompt, poll for progress, and receive a permanent CDN-hosted video URL.

Supported Models

ModelProviderTypeMax DurationNotes
google/veo-3.1Google VertexText-to-video8 secondsHighest quality
google/veo-3.1-fastGoogle VertexText-to-video8 secondsFaster generation
google/veo-3.1-liteGoogle VertexText-to-video8 secondsMost affordable
bedrock/nova-reel-1.1Amazon BedrockText-to-video6 seconds
bedrock/nova-reel-1.0Amazon BedrockText-to-video6 seconds
bailian/happyhorse-1.0-t2vAlibaba BailianText-to-video15 secondsAudio output, 720P/1080P
bailian/happyhorse-1.0-i2vAlibaba BailianImage-to-video15 secondsRequires source image
bailian/happyhorse-1.0-r2vAlibaba BailianReference-to-video15 secondsMultiple reference images
bailian/happyhorse-1.0-video-editAlibaba BailianVideo edit15 secondsRequires source video
bailian/wan2.7-t2vAlibaba BailianText-to-video5 seconds
bailian/wan2.6-t2vAlibaba BailianText-to-video5 seconds
bailian/wan2.6-i2vAlibaba BailianImage-to-video5 secondsRequires source image

Text-to-Video

Submit a video generation request with a text prompt:

terminal
bash
curl -X POST https://api.chuizi.ai/v1/videos/generations \
  -H "Authorization: Bearer ck-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "google/veo-3.1",
    "prompt": "A golden retriever running through a sunlit meadow, slow motion, cinematic",
    "duration": 5
  }'

Response (immediate):

config.json
json
{
  "id": "gen-xxxxxxxxxxxxxxxx",
  "status": "processing",
  "created": 1712000000
}

The video is not ready yet. You need to poll for the result.

Image-to-Video

For models that support image-to-video (e.g., bailian/wan2.6-i2v), include a source image:

terminal
bash
curl -X POST https://api.chuizi.ai/v1/videos/generations \
  -H "Authorization: Bearer ck-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bailian/wan2.6-i2v",
    "prompt": "The person in the photo starts walking forward",
    "image": "https://example.com/photo.jpg",
    "duration": 5
  }'

Reference-to-Video

HappyHorse reference-to-video accepts one or more reference images. Mention them in your prompt as Image 1, Image 2, etc.:

terminal
bash
curl -X POST https://api.chuizi.ai/v1/videos/generations \
  -H "Authorization: Bearer ck-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bailian/happyhorse-1.0-r2v",
    "prompt": "Use Image 1 as the character and Image 2 as the outfit reference, cinematic camera move",
    "reference_image_urls": [
      "https://example.com/character.jpg",
      "https://example.com/outfit.jpg"
    ],
    "duration": 5,
    "resolution": "720P"
  }'

Video Editing

HappyHorse video edit takes a public source video URL plus optional reference images:

terminal
bash
curl -X POST https://api.chuizi.ai/v1/videos/generations \
  -H "Authorization: Bearer ck-your-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "bailian/happyhorse-1.0-video-edit",
    "prompt": "Change the jacket to the striped sweater from Image 1",
    "video_url": "https://example.com/source.mp4",
    "reference_image_urls": ["https://example.com/sweater.png"],
    "resolution": "720P"
  }'

Async Polling

Video generation takes 30 seconds to several minutes depending on the model and duration. Poll the video result endpoint to check status:

terminal
bash
curl https://api.chuizi.ai/v1/videos/gen-xxxxxxxxxxxxxxxx \
  -H "Authorization: Bearer ck-your-key-here"

Processing (not ready yet)

config.json
json
{
  "id": "gen-xxxxxxxxxxxxxxxx",
  "status": "processing",
  "created": 1712000000
}

Completed

config.json
json
{
  "id": "gen-xxxxxxxxxxxxxxxx",
  "status": "succeeded",
  "model": "google/veo-3.1-fast",
  "url": "https://media.chuizi.ai/videos/gen-xxxxxxxxxxxxxxxx.mp4",
  "video_url": "https://media.chuizi.ai/videos/gen-xxxxxxxxxxxxxxxx.mp4",
  "cost": "0.15000000",
  "latency_ms": 45000,
  "created": 1712000000
}

Failed

config.json
json
{
  "id": "gen-xxxxxxxxxxxxxxxx",
  "status": "failed",
  "error": {
    "message": "Content policy violation",
    "type": "invalid_request_error"
  }
}

CDN Delivery

Generated videos are stored on media.chuizi.ai (Cloudflare R2 CDN). URLs are permanent and do not expire. You can use them directly in your application or download them.

Code Examples

example.py
python
import time
import requests
from openai import OpenAI

client = OpenAI(
    base_url="https://api.chuizi.ai/v1",
    api_key="ck-your-key-here",
)

# Step 1: Submit the video generation request
response = requests.post(
    "https://api.chuizi.ai/v1/videos/generations",
    headers={
        "Authorization": "Bearer ck-your-key-here",
        "Content-Type": "application/json",
    },
    json={
        "model": "google/veo-3.1-fast",
        "prompt": "A cat sitting on a windowsill watching rain fall outside, cozy atmosphere",
        "duration": 5,
    },
)
result = response.json()
generation_id = result["id"]
print(f"Video generation started: {generation_id}")

# Step 2: Poll for completion
while True:
    status_response = requests.get(
        f"https://api.chuizi.ai/v1/videos/{generation_id}",
        headers={"Authorization": "Bearer ck-your-key-here"},
    )
    status = status_response.json()

    if status["status"] == "succeeded":
        print(f"Video ready: {status.get('video_url') or status.get('url')}")
        break
    elif status["status"] == "failed":
        print(f"Generation failed: {status['error']['message']}")
        break
    else:
        print("Still processing... waiting 10 seconds")
        time.sleep(10)

Tips

  • Set long timeouts. Video generation can take 30 seconds to 3 minutes. Your polling logic should wait at least 5 minutes before giving up.
  • Poll every 10 seconds. Polling too frequently wastes resources. Every 10 seconds is sufficient.
  • Check content policies. Video generation models have strict content moderation. Prompts that violate content policies will be rejected.
  • Use the fast or lite variants for testing and prototyping. Switch to the full model for production quality.
  • Videos are billed per generation, not per token. Check the pricing page for per-model generation costs.

Next Steps