Chameleon

Video Generation

Generate videos with AI using Kling and Seedance

Video Generation

Create AI-generated videos from text prompts using Kling AI or Seedance (Volcengine).

Supported Providers

Seedance (Volcengine ARK) - Recommended

Model: doubao-seedance-1-0-pro-250528

Features:

  • High-quality video generation
  • 5-second videos
  • 1080p resolution
  • Fast processing (1-2 minutes)

Cost: 10 credits per video

API Key: Get from Volcengine ARK Console

Kling AI

Models: kling-v1, kling-v1-6

Features:

  • Professional video quality
  • Variable duration
  • Multiple aspect ratios

Cost: 10 credits per video

API Key: Get from Kling AI Platform

Quick Start

Using AI Generator UI

  1. Visit /ai-generator
  2. Select Video Generation
  3. Choose Seedance (default)
  4. Enter prompt:
    A drone flying through a canyon at high speed
    
  5. Click Generate
  6. Wait 1-2 minutes
  7. Download your video!

Using API

const response = await fetch("/api/generator/generate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    ai_type: "video",
    provider: "seedance",
    model: "doubao-seedance-1-0-pro-250528",
    prompt: "A cat playing piano in a jazz club",
    options: {},
  }),
});

const data = await response.json();
const genId = data.data.gen_id;

// Poll for results
// See AI APIs documentation

Prompt Engineering

Good Prompts

Specific and descriptive:

A professional chef preparing sushi in a modern kitchen, 
cinematic lighting, high quality

Include style and mood:

Aerial drone footage of a tropical beach at golden hour, 
calm waves, peaceful atmosphere

Mention camera movement:

Camera slowly zooming into a blooming flower, 
macro photography style

Bad Prompts

Too vague:

A video

Too complex:

A dragon fighting a robot while a princess watches from a castle 
on a floating island during a thunderstorm with rainbow

Conflicting instructions:

Dark and bright forest scene

Seedance-Specific Options

Add options to your prompt with -- flags:

Your prompt text --ratio 16:9 --duration 5 --camerafixed false

Available Options:

  • --ratio 16:9 or --ratio 9:16 - Aspect ratio
  • --duration 5 - Video length in seconds
  • --camerafixed false - Allow camera movement
  • --watermark true - Add watermark

Example:

A sports car racing through city streets 
--ratio 16:9 --duration 5 --camerafixed false

Configuration

Environment Variables

# Seedance (Volcengine ARK)
SEEDANCE_API_KEY="your-ark-api-key"

# Kling AI
KLING_ACCESS_KEY="your-kling-key"

Admin Configuration

Configure in UI at /admin/ai-config:

  1. Login as admin
  2. Click seedance or kling
  3. Enter API key
  4. Enable provider
  5. Save

Keys stored in database with 5-minute cache.

Generation Process

Workflow

1. Submit prompt
   ↓
2. Task created (status: pending)
   ↓
3. AI processes (status: processing)
   ↓ 1-5 minutes
4. Video ready (status: completed)
   ↓
5. Credits deducted (only on success)

Status Tracking

Poll the status every 3-5 seconds:

const pollStatus = async (genId: string) => {
  const response = await fetch("/api/generator/query", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({ gen_id: genId }),
  });
  
  const data = await response.json();
  const { status, result_urls, error_message } = data.data;
  
  if (status === "completed") {
    console.log("Video URL:", result_urls[0]);
    // Display video
  } else if (status === "failed") {
    console.error("Error:", error_message);
  } else {
    // Still processing, poll again
    setTimeout(() => pollStatus(genId), 3000);
  }
};

Download and Storage

Temporary URLs

Result URLs from AI providers are temporary and typically expire after:

  • Seedance: 24 hours
  • Kling: 7 days

Download important videos immediately. URLs will expire and cannot be recovered.

Permanent Storage (Optional)

To store videos permanently:

  1. Download the video
  2. Upload to your storage:
    • AWS S3
    • Cloudflare R2
    • Vercel Blob Storage
// Example: Save to Vercel Blob
import { put } from '@vercel/blob';

const videoBlob = await fetch(result_urls[0]).then(r => r.blob());
const { url } = await put(`videos/${genId}.mp4`, videoBlob, {
  access: 'public',
});

// Update database with permanent URL
await updateGenerationResultUrl(genId, url);

Cost Optimization

Tips to Reduce Costs

  1. Use Seedance for most cases:

    • Good quality, fast processing
    • Same cost as Kling but faster
  2. Test prompts with image generation first:

    • Images cost only 3-5 credits
    • Iterate on prompts cheaply
    • Then generate video
  3. Batch generations:

    • Generate multiple videos at once
    • More efficient use of credits
  4. Monitor failed generations:

    • Failed gens don't cost credits
    • But fix issues to avoid waste

Limitations

Current Limitations

  • Duration: 5 seconds (Seedance), variable (Kling)
  • Resolution: 1080p max
  • No audio: Generated videos have no sound
  • Processing time: 1-5 minutes per video
  • No editing: Videos are generated as-is

Provider Limits

  • Seedance: May have daily generation limits
  • Kling: API rate limits apply
  • Check provider documentation for specifics

Examples

Example 1: Product Demo

{
  "ai_type": "video",
  "provider": "seedance",
  "model": "doubao-seedance-1-0-pro-250528",
  "prompt": "360-degree product rotation of a modern smartwatch, white background, professional lighting --ratio 1:1",
  "options": {}
}

Example 2: Nature Scene

{
  "ai_type": "video",
  "provider": "seedance",
  "model": "doubao-seedance-1-0-pro-250528",
  "prompt": "Sunrise over mountain range, time-lapse style, warm golden light --ratio 16:9 --duration 5",
  "options": {}
}

Example 3: Action Scene

{
  "ai_type": "video",
  "provider": "kling",
  "model": "kling-v1",
  "prompt": "Skateboard trick in slow motion, urban environment, dynamic camera following the action",
  "options": {}
}

Troubleshooting

Video quality is poor

Try:

  • More detailed prompts
  • Specify "high quality", "4K", "professional"
  • Try different provider
  • Adjust resolution in options

Video doesn't match prompt

Solutions:

  • Make prompt more specific
  • Avoid conflicting instructions
  • Simplify complex scenes
  • Regenerate with refined prompt

Generation fails repeatedly

Check:

  1. API key is valid
  2. Provider service is online
  3. Prompt doesn't violate content policy
  4. Account has available quota

Debug:

Check Vercel logs for:
- "Seedance task created, task_id: ..."
- "Seedance query result: ..."
- Look for error messages

Next Steps