Skip to main content
The Decart provider for the Vercel AI SDK adds image and video generation to any AI SDK project.

Prerequisites

Installation

npm install @decartai/ai-sdk-provider

Setup

Import the default provider instance:
import { decart } from '@decartai/ai-sdk-provider';
The provider reads your API key from the DECART_API_KEY environment variable by default. Set your Decart API key as an environment variable:
export DECART_API_KEY="your-api-key"
Get your API key from platform.decart.ai. See authentication for details. For custom configuration, use createDecart():
import { createDecart } from '@decartai/ai-sdk-provider';

const decart = createDecart({
  apiKey: 'your-api-key',
  baseURL: 'https://api.decart.ai',
});
apiKey
string
API key for authentication. Defaults to the DECART_API_KEY environment variable.
baseURL
string
Custom URL prefix for API calls. Defaults to https://api.decart.ai.
headers
Record<string, string>
Custom headers to include in requests.
fetch
(input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation for intercepting requests or testing.

Image generation

Generate images with generateImage():
import { decart } from '@decartai/ai-sdk-provider';
import { generateImage } from 'ai';
import fs from 'fs';

const { image } = await generateImage({
  model: decart.image('lucy-pro-t2i'),
  prompt: 'A golden retriever sitting in a field of wildflowers at sunset',
});

const filename = `image-${Date.now()}.png`;
fs.writeFileSync(filename, image.uint8Array);
console.log(`Image saved to ${filename}`);

Image models

ModelDescription
lucy-pro-t2iHigh-quality text-to-image generation

Image settings

aspectRatio
string
Aspect ratio of the generated image. Supported values: 16:9 (landscape) and 9:16 (portrait).
seed
number
Seed value for reproducible results.
Unsupported aspect ratios generate a warning and fall back to the default behavior.
const { image } = await generateImage({
  model: decart.image('lucy-pro-t2i'),
  prompt: 'A minimalist Japanese garden with cherry blossoms',
  aspectRatio: '16:9',
  seed: 42,
});

Video generation

Generate videos with experimental_generateVideo():
experimental_generateVideo is an experimental AI SDK API. The function signature may change in future releases.

Text-to-video

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

const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A horse galloping through a sunlit meadow',
});

fs.writeFileSync('video.mp4', videos[0].uint8Array);

Image-to-video

Animate a static image into a video:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-i2v'),
  prompt: {
    image: imageData,
    text: 'The subject begins to walk forward slowly',
  },
});

Motion control

Use lucy-motion with a trajectory to control camera or subject movement:
const { videos } = await generateVideo({
  model: decart.video('lucy-motion'),
  prompt: {
    image: imageData,
    text: 'The subject moves along the specified path',
  },
  providerOptions: {
    decart: {
      trajectory: [
        { frame: 0, x: 0.5, y: 0.5 },
        { frame: 12, x: 0.7, y: 0.9 },
        { frame: 25, x: 0.3, y: 0.1 },
      ],
    },
  },
});

Video models

ModelDescription
lucy-pro-t2vText-to-video generation
lucy-pro-i2vImage-to-video generation
lucy-dev-i2vImage-to-video generation (dev)
lucy-motionImage-to-video with trajectory-based motion control

Video settings

aspectRatio
string
Aspect ratio of the generated video. Supported values: 16:9 (landscape) and 9:16 (portrait).
seed
number
Seed value for reproducible results.
resolution
string
Video resolution. Supported values: 1280x720 (720p) and 854x480 (480p).

Provider options

Pass Decart-specific options via providerOptions.decart:
trajectory
Array<{ frame: number; x: number; y: number }>
Motion path for lucy-motion. Each point specifies a frame number and normalized x/y coordinates (0–1).
orientation
"landscape" | "portrait"
Override orientation directly instead of deriving it from aspectRatio.

Next steps

Models overview

Explore all available Decart models.

JavaScript SDK

Use Decart’s native SDK for full API access.

GitHub

View source code and contribute.