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:
Import the required functions
import { decart } from '@decartai/ai-sdk-provider' ;
import { generateImage } from 'ai' ;
import fs from 'fs' ;
Generate an image
const { image } = await generateImage ({
model: decart . image ( 'lucy-pro-t2i' ),
prompt: 'Three dogs playing in the snow' ,
});
Save the image
const filename = `image- ${ Date . now () } .png` ;
fs . writeFileSync ( filename , image . uint8Array );
console . log ( `Image saved to ${ filename } ` );
Complete Example
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:
Import the required functions
import { decart } from '@decartai/ai-sdk-provider' ;
import { experimental_generateVideo as generateVideo } from 'ai' ;
import fs from 'fs' ;
Generate a video
const { videos } = await generateVideo ({
model: decart . video ( 'lucy-pro-t2v' ),
prompt: 'A man is riding a horse in a field' ,
});
Save the video
fs . writeFileSync ( 'video.mp4' , videos [ 0 ]. uint8Array );
console . log ( 'Video saved to video.mp4' );
Complete Example
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:
Landscape (16:9)
Portrait (9:16)
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 Found If 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 Found If 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