> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.decart.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Generate images and videos with Decart using the Vercel AI SDK.

The Decart provider for the [Vercel AI SDK](https://ai-sdk.dev/docs) adds image and video generation to any AI SDK project.

## Prerequisites

* A [Decart API key](/getting-started/authentication)
* Node.js 18+
* The `ai` package (`npm i ai`)

## Installation

<CodeGroup>
  ```bash npm theme={null}
  npm install @decartai/ai-sdk-provider
  ```

  ```bash pnpm theme={null}
  pnpm add @decartai/ai-sdk-provider
  ```

  ```bash yarn theme={null}
  yarn add @decartai/ai-sdk-provider
  ```
</CodeGroup>

## Setup

Import the default provider instance:

```typescript theme={null}
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:

```bash theme={null}
export DECART_API_KEY="your-api-key"
```

Get your API key from [platform.decart.ai](https://platform.decart.ai). See [authentication](/getting-started/authentication) for details.

For custom configuration, use `createDecart()`:

```typescript theme={null}
import { createDecart } from '@decartai/ai-sdk-provider';

const decart = createDecart({
  apiKey: 'your-api-key',
  baseURL: 'https://api.decart.ai',
});
```

<ParamField body="apiKey" type="string">
  API key for authentication. Defaults to the `DECART_API_KEY` environment variable.
</ParamField>

<ParamField body="baseURL" type="string">
  Custom URL prefix for API calls. Defaults to `https://api.decart.ai`.
</ParamField>

<ParamField body="headers" type="Record<string, string>">
  Custom headers to include in requests.
</ParamField>

<ParamField body="fetch" type="(input: RequestInfo, init?: RequestInit) => Promise<Response>">
  Custom fetch implementation for intercepting requests or testing.
</ParamField>

## Image generation

Generate images with [`generateImage()`](https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-image):

```typescript theme={null}
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

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

### Image settings

<ParamField body="aspectRatio" type="string">
  Aspect ratio of the generated image. Supported values: `16:9` (landscape) and `9:16` (portrait).
</ParamField>

<ParamField body="seed" type="number">
  Seed value for reproducible results.
</ParamField>

<Note>
  Unsupported aspect ratios generate a warning and fall back to the default behavior.
</Note>

```typescript theme={null}
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()`](https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-video):

<Note>
  `experimental_generateVideo` is an experimental AI SDK API. The function signature may change in future releases.
</Note>

### Text-to-video

```typescript theme={null}
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);
```

### Video models

| Model          | Description              |
| -------------- | ------------------------ |
| `lucy-pro-t2v` | Text-to-video generation |

### Video settings

<ParamField body="aspectRatio" type="string">
  Aspect ratio of the generated video. Supported values: `16:9` (landscape) and `9:16` (portrait).
</ParamField>

<ParamField body="seed" type="number">
  Seed value for reproducible results.
</ParamField>

<ParamField body="resolution" type="string">
  Video resolution. Supported values: `1280x720` (720p) and `854x480` (480p).
</ParamField>

### Provider options

Pass Decart-specific options via `providerOptions.decart`:

<ParamField body="orientation" type={'"landscape" | "portrait"'}>
  Override orientation directly instead of deriving it from `aspectRatio`.
</ParamField>

## Next steps

<CardGroup cols={3}>
  <Card title="Models overview" icon="layer-group" href="/getting-started/models">
    Explore all available Decart models.
  </Card>

  <Card title="JavaScript SDK" icon="js" href="/sdks/javascript">
    Use Decart's native SDK for full API access.
  </Card>

  <Card title="GitHub" icon="github" href="https://github.com/DecartAI/ai-sdk-provider">
    View source code and contribute.
  </Card>
</CardGroup>
