> ## 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

> Generate your first images and videos with the Decart AI SDK Provider

# 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](/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:

<Steps>
  <Step title="Import the required functions">
    ```typescript theme={null}
    import { decart } from '@decartai/ai-sdk-provider';
    import { generateImage } from 'ai';
    import fs from 'fs';
    ```
  </Step>

  <Step title="Generate an image">
    ```typescript theme={null}
    const { image } = await generateImage({
      model: decart.image('lucy-pro-t2i'),
      prompt: 'Three dogs playing in the snow',
    });
    ```
  </Step>

  <Step title="Save the image">
    ```typescript theme={null}
    const filename = `image-${Date.now()}.png`;
    fs.writeFileSync(filename, image.uint8Array);
    console.log(`Image saved to ${filename}`);
    ```
  </Step>
</Steps>

### Complete Example

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

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

<Info>
  The `image.uint8Array` property contains the raw image data in PNG format.
</Info>

## Generate Your First Video

Now let's create a video from a text prompt:

<Steps>
  <Step title="Import the required functions">
    ```typescript theme={null}
    import { decart } from '@decartai/ai-sdk-provider';
    import { experimental_generateVideo as generateVideo } from 'ai';
    import fs from 'fs';
    ```
  </Step>

  <Step title="Generate a video">
    ```typescript theme={null}
    const { videos } = await generateVideo({
      model: decart.video('lucy-pro-t2v'),
      prompt: 'A man is riding a horse in a field',
    });
    ```
  </Step>

  <Step title="Save the video">
    ```typescript theme={null}
    fs.writeFileSync('video.mp4', videos[0].uint8Array);
    console.log('Video saved to video.mp4');
    ```
  </Step>
</Steps>

### Complete Example

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

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

<Note>
  The `experimental_generateVideo` function is part of the AI SDK's experimental API for video generation.
</Note>

## Customizing Generation

### Control Aspect Ratio

Both image and video generation support aspect ratio customization:

<CodeGroup>
  ```typescript Landscape (16:9) theme={null}
  const { image } = await generateImage({
    model: decart.image('lucy-pro-t2i'),
    prompt: 'A panoramic mountain landscape',
    aspectRatio: '16:9',
  });
  ```

  ```typescript Portrait (9:16) theme={null}
  const { image } = await generateImage({
    model: decart.image('lucy-pro-t2i'),
    prompt: 'A tall building reaching into the clouds',
    aspectRatio: '9:16',
  });
  ```
</CodeGroup>

### Reproducible Results with Seeds

Use a seed value to get consistent outputs:

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

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

<CardGroup cols={2}>
  <Card title="Image Generation" icon="image" href="/image/overview">
    Deep dive into text-to-image generation with lucy-pro-t2i
  </Card>

  <Card title="Video Generation" icon="video" href="/video/overview">
    Learn about text-to-video and image-to-video generation
  </Card>

  <Card title="Motion Control" icon="route" href="/video/motion-control">
    Control camera movement with trajectory-based generation
  </Card>

  <Card title="API Reference" icon="code" href="/api/decart-provider">
    Explore all available models and settings
  </Card>
</CardGroup>

## Common Issues

<Tip>
  **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
</Tip>

<Tip>
  **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
</Tip>
