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.

Quickstart Guide

Get up and running quickly with the Decart AI SDK Provider. This guide will walk you through generating your first image and video.

Prerequisites

Make sure you’ve completed the Installation steps:
  • Installed @decartai/ai-sdk-provider and ai packages
  • Set up your DECART_API_KEY environment variable
  • Using Node.js 18 or higher

Generate Your First Image

Let’s create a simple image from a text prompt:
1

Import the required functions

import { decart } from '@decartai/ai-sdk-provider';
import { generateImage } from 'ai';
import fs from 'fs';
2

Generate an image

const { image } = await generateImage({
  model: decart.image('lucy-pro-t2i'),
  prompt: 'Three dogs playing in the snow',
});
3

Save the image

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

Complete Example

image-generation.ts
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: 'Three dogs playing in the snow',
});

const filename = `image-${Date.now()}.png`;
fs.writeFileSync(filename, image.uint8Array);
console.log(`Image saved to ${filename}`);
The image.uint8Array property contains the raw image data in PNG format.

Generate Your First Video

Now let’s create a video from a text prompt:
1

Import the required functions

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

Generate a video

const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A man is riding a horse in a field',
});
3

Save the video

fs.writeFileSync('video.mp4', videos[0].uint8Array);
console.log('Video saved to video.mp4');

Complete Example

video-generation.ts
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 man is riding a horse in a field',
});

fs.writeFileSync('video.mp4', videos[0].uint8Array);
console.log('Video saved to video.mp4');
The experimental_generateVideo function is part of the AI SDK’s experimental API for video generation.

Customizing Generation

Control Aspect Ratio

Both image and video generation support aspect ratio customization:
const { image } = await generateImage({
  model: decart.image('lucy-pro-t2i'),
  prompt: 'A panoramic mountain landscape',
  aspectRatio: '16:9',
});

Reproducible Results with Seeds

Use a seed value to get consistent outputs:
const { image } = await generateImage({
  model: decart.image('lucy-pro-t2i'),
  prompt: 'Three dogs playing in the snow',
  seed: 42, // Same seed will produce the same image
});

Video Resolution

Control video quality with the resolution parameter:
const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A sunset over the ocean',
  resolution: '1280x720', // 720p quality
});
Supported resolutions:
  • 1280x720 (720p, default)
  • 854x480 (480p)

Next Steps

Now that you’ve generated your first image and video, explore more advanced features:

Image Generation

Deep dive into text-to-image generation with lucy-pro-t2i

Video Generation

Learn about text-to-video and image-to-video generation

Motion Control

Control camera movement with trajectory-based generation

API Reference

Explore all available models and settings

Common Issues

API Key Not FoundIf you see an error about missing API key:
  • Verify DECART_API_KEY is set in your environment
  • Check your .env file is in the correct directory
  • Restart your development server after setting environment variables
Module Not FoundIf you encounter import errors:
  • Ensure both @decartai/ai-sdk-provider and ai are installed
  • Check you’re using Node.js 18 or higher
  • Try clearing your node_modules and reinstalling

Build docs developers (and LLMs) love