Skip to content

DecartAI/ai-sdk-provider

Repository files navigation

AI SDK - Decart Provider

The Decart provider for the AI SDK contains support for Decart's image and video generation models.

Setup

The Decart provider is available in the @decartai/ai-sdk-provider module. You can install it with:

npm i @decartai/ai-sdk-provider

Provider Instance

You can import the default provider instance decart from @decartai/ai-sdk-provider:

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

If you need a customized setup, you can import createDecart and create a provider instance with your settings:

import { createDecart } from '@decartai/ai-sdk-provider';

const decart = createDecart({
  apiKey: 'your-api-key', // optional, defaults to DECART_API_KEY environment variable
  baseURL: 'custom-url', // optional
  headers: {
    /* custom headers */
  }, // optional
});

You can use the following optional settings to customize the Decart provider instance:

  • baseURL string

    Use a different URL prefix for API calls, e.g. to use proxy servers. The default prefix is https://api.decart.ai.

  • apiKey string

    API key that is being sent using the X-API-KEY header. It defaults to the DECART_API_KEY environment variable.

  • headers Record<string,string>

    Custom headers to include in the requests.

  • fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>

    Custom fetch implementation. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing.

Image Models

You can create Decart image models using the .image() factory method. For more on image generation with the AI SDK see generateImage().

Basic Usage

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}`);

Model Capabilities

Decart currently offers:

Model Description
lucy-pro-t2i High-quality text-to-image generation model

The model supports the following aspect ratios:

  • 16:9 (landscape)
  • 9:16 (portrait)
Other aspect ratios will generate a warning and fall back to the default behavior.

Image Model Settings

You can customize the generation behavior with optional settings:

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

Supported settings:

  • aspectRatio string

    Control the aspect ratio of the generated image. Supported values: 16:9 (landscape) and 9:16 (portrait).

  • seed number

    Set a seed value for reproducible results.

Video Models

You can create Decart video models using the .video() factory method. For more on video generation with the AI SDK see experimental_generateVideo().

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

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

Image-to-Video

Pass an image to animate it 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 },
      ],
    },
  },
});

Model Capabilities

Model Description
lucy-pro-t2v Text-to-video generation
lucy-pro-i2v Image-to-video generation
lucy-dev-i2v Image-to-video generation (dev)
lucy-motion Image-to-video with trajectory-based motion control

Video Model Settings

const { videos } = await generateVideo({
  model: decart.video('lucy-pro-t2v'),
  prompt: 'A sunset over the ocean',
  aspectRatio: '16:9',
  seed: 42,
});

Supported settings:

  • aspectRatio string

    Control the aspect ratio. Supported values: 16:9 (landscape) and 9:16 (portrait).

  • seed number

    Set a 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.

  • orientation "landscape" | "portrait"

    Override orientation directly instead of deriving from aspectRatio.

Learn More

For more details about Decart's capabilities and features, visit Decart AI.

About

Decart provider for AI SDK

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors