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 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 { experimental_generateImage as 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.

Learn More

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