Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/DecartAI/ai-sdk-provider/llms.txt

Use this file to discover all available pages before exploring further.

The lucy-pro-t2v model generates videos directly from text descriptions without requiring an input image. This is ideal for creating videos from scratch based on natural language prompts.

Basic Usage

1

Import Dependencies

Import the Decart provider and the experimental video generation function:
import { decart } from '@decartai/ai-sdk-provider';
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'fs';
2

Generate Video

Call generateVideo with the lucy-pro-t2v model and your text prompt:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A man is riding a horse in a field',
});
Source Reference: examples/tasks/video-generation-t2v.ts:7-10
3

Save the Video

Write the generated video to a file:
fs.writeFileSync('video.mp4', videos[0].uint8Array);

Complete Example

import { decart } from '@decartai/ai-sdk-provider';
import { experimental_generateVideo as generateVideo } from 'ai';
import fs from 'fs';

export async function generateTextToVideo() {
  const result = await generateVideo({
    model: decart.video('lucy-pro-t2v'),
    prompt: 'A man is riding a horse in a field',
  });
  
  const filename = `video-${Date.now()}.mp4`;
  fs.writeFileSync(filename, result.videos[0].uint8Array);
  console.log(`Video saved to ${filename}`);
  
  return result;
}

Customizing Output

Aspect Ratio

Control video orientation with the aspectRatio parameter:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A sunset over the ocean',
  aspectRatio: '16:9',
});
The aspectRatio parameter is converted to an orientation value (landscape or portrait) in the API request.Source Reference: src/decart-video-model.ts:110-122

Resolution

Set video resolution using the resolution parameter:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A city skyline at night',
  resolution: '1280x720',
});
Only 1280x720 (720p) and 854x480 (480p) resolutions are supported. Other values will generate a warning.Source Reference: src/decart-video-model.ts:125-135

Reproducible Results

Use the seed parameter to generate reproducible videos:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A tranquil lake surrounded by mountains',
  seed: 42,
});
Using the same prompt, seed, and settings will produce the same video output.Source Reference: src/decart-video-model.ts:152-154

Advanced Configuration

Custom Polling Behavior

Video generation is asynchronous. Customize the polling behavior:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A spaceship flying through space',
  providerOptions: {
    decart: {
      pollIntervalMs: 2000,  // Poll every 2 seconds (default: 1500)
      pollTimeoutMs: 600000, // 10 minute timeout (default: 300000)
    },
  },
});
pollIntervalMs
number
default:"1500"
Time in milliseconds between status checks during video generation.Source Reference: src/decart-video-model.ts:196
pollTimeoutMs
number
default:"300000"
Maximum time in milliseconds to wait for video generation (default: 5 minutes).Source Reference: src/decart-video-model.ts:197

Abort Signal

Cancel long-running video generation requests:
const controller = new AbortController();

// Cancel after 2 minutes
setTimeout(() => controller.abort(), 120000);

const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A long animation sequence',
  abortSignal: controller.signal,
});
Source Reference: src/decart-video-model.ts:204-209

Writing Effective Prompts

  • Be specific about the subject, action, and environment
  • Include motion or camera movement descriptions
  • Specify lighting, weather, or atmosphere when relevant
  • Keep prompts concise but descriptive (1-2 sentences)
Good Examples:
  • “A golden retriever running through a sunny meadow with wildflowers”
  • “Aerial view of a city at sunset, camera slowly panning across skyscrapers”
  • “Close-up of raindrops falling on a window with a blurred cityscape behind”
Less Effective:
  • “A dog” (too vague)
  • “A detailed scene with a dog running in a field with flowers and trees and mountains in the background on a sunny day…” (too long)

Response Structure

The generateVideo function returns a result object:
const result = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A peaceful forest scene',
});

// Access the video
const video = result.videos[0];
console.log(video.mimeType);      // "video/mp4"
console.log(video.uint8Array);    // Uint8Array containing video data

// Access response metadata
console.log(result.response.modelId);    // "lucy-pro-t2v"
console.log(result.response.timestamp);  // Date object
Source Reference: src/decart-video-model.ts:247-261

Error Handling

try {
  const { videos } = await generateVideo({
    model: decart.video('lucy-pro-t2v'),
    prompt: 'A dramatic storm approaching',
  });
  
  fs.writeFileSync('storm.mp4', videos[0].uint8Array);
} catch (error) {
  if (error.name === 'AI_APICallError') {
    console.error('Video generation failed:', error.message);
  }
  throw error;
}
Common errors include timeout (exceeding 5 minutes), job failure, or network issues.Source References:
  • Timeout error: src/decart-video-model.ts:211-216
  • Job failure: src/decart-video-model.ts:230-235

Next Steps

Image-to-Video

Animate existing images into videos

Motion Control

Control camera and subject movement

Settings Reference

View all configuration options

Examples

Browse complete working examples

Build docs developers (and LLMs) love