Skip to main content

Installation

Get started with the Decart AI SDK Provider by installing the package and configuring your API credentials.

Prerequisites

Before you begin, ensure you have:
  • Node.js 18 or higher installed on your system
  • npm, yarn, or pnpm package manager
  • A Decart API key (see Getting Your API Key below)

Install the Package

Install the Decart AI SDK Provider using your preferred package manager:
The ai package is a peer dependency that provides the core AI SDK functionality like generateImage() and experimental_generateVideo().

Getting Your API Key

To use the Decart AI SDK Provider, you’ll need an API key from Decart:
1

Visit Decart

Go to decart.ai and create an account if you don’t have one
2

Access API Settings

Navigate to your account settings or API section
3

Generate API Key

Create a new API key for your application
4

Save Securely

Store your API key securely - you’ll need it for configuration

Configure Your API Key

There are two ways to provide your API key to the Decart provider: Set the DECART_API_KEY environment variable:
For local development, add it to your .env file:
.env
Never commit your .env file or expose your API key in client-side code. Always keep your API keys secure.
Then use the default provider instance:

Programmatic Configuration

Alternatively, pass the API key directly when creating a custom provider instance:

Advanced Configuration

For advanced use cases, you can customize the provider with additional options:

Configuration Options

  • apiKey string Your Decart API key. Defaults to the DECART_API_KEY environment variable.
  • baseURL string Custom API endpoint URL. Defaults to https://api.decart.ai. Useful for proxy servers or testing.
  • headers Record<string, string> Additional HTTP headers to include in every request.
  • fetch FetchFunction Custom fetch implementation. Useful for middleware, request interception, or testing.

Verification

Verify your installation by running a simple test:
If you encounter any issues, check that:
  • Your API key is correctly set
  • You’re using Node.js 18 or higher
  • Both @decartai/ai-sdk-provider and ai packages are installed

Next Steps

Quickstart Guide

Learn how to generate your first images and videos with practical examples