Skip to main content

GitHub

View source code and contribute

Installation

npm install @decartai/sdk
# or
pnpm add @decartai/sdk
# or
yarn add @decartai/sdk

Quick Start

import { createDecartClient, models } from "@decartai/sdk";
import { writeFileSync } from "fs";

const client = createDecartClient({
  apiKey: process.env.DECART_API_KEY,
});

// Generate a video from text using the Queue API
const result = await client.queue.submitAndPoll({
  model: models.video("lucy-pro-t2v"),
  prompt: "A cat walking in a lego world",
  resolution: "720p",
  onStatusChange: (job) => {
    console.log(`Status: ${job.status}`);
  },
});

if (result.status === "completed") {
  const buffer = Buffer.from(await result.data.arrayBuffer());
  writeFileSync("output.mp4", buffer);
  console.log("Video saved!");
}

What can you build?

The SDK provides three main APIs for different use cases:
If you need to…UseMain method
Transform live streams over WebRTCRealtime APIclient.realtime.connect()
Generate/edit videos asynchronouslyQueue APIclient.queue.submitAndPoll()
Generate/edit images synchronouslyProcess APIclient.process()
If you’re building a browser app and want to avoid exposing API keys, route SDK calls through your backend proxy. See the proxy examples in sdks/sdk/examples/nextjs-proxy and sdks/sdk/examples/express-proxy.

Client Setup

All APIs share the same client initialization:
import { createDecartClient } from "@decartai/sdk";

const client = createDecartClient({
  apiKey: process.env.DECART_API_KEY,
  baseUrl: "https://custom-endpoint.com", // optional
  telemetry: true, // optional, defaults to true
});
Parameters:
  • apiKey (required) - Your Decart API key from the platform
  • baseUrl (optional) - Custom API endpoint (defaults to Decart’s production API)
  • telemetry (optional) - Enable SDK telemetry for realtime observability (default: true)
Store your API key in environment variables. Never commit API keys to version control.

Client Tokens

For client-side applications (browsers, mobile apps) using the Realtime API, create short-lived client tokens instead of exposing your permanent API key:
// On your backend
const { apiKey, expiresAt } = await client.tokens.create();
// Send apiKey to your frontend for secure client-side authentication
See Client Tokens for details on secure realtime auth.

Available Models

Import models from the SDK to use with either API:
import { models } from "@decartai/sdk";

// Video models
models.video("lucy-pro-t2v");         // Text-to-video
models.video("lucy-pro-i2v");         // Image-to-video
models.video("lucy-dev-i2v");         // Image-to-video (dev)
models.video("lucy-pro-v2v");         // Video-to-video
models.video("lucy-fast-v2v");        // Video-to-video (fast)

// Image models
models.image("lucy-pro-t2i");         // Text-to-image
models.image("lucy-pro-i2i");         // Image-to-image

// Realtime models
models.realtime("mirage");            // Realtime video transformation
models.realtime("mirage_v2");         // Realtime video transformation (v2)
models.realtime("lucy_v2v_720p_rt");  // Realtime video editing
models.realtime("lucy_2_rt");         // Realtime video editing with character reference
models.realtime("live_avatar");       // Avatar animation with audio

TypeScript Support

The SDK is written in TypeScript with full type definitions. Each model enforces its own required inputs, so you’ll get autocomplete and helpful errors if something is missing.
// Image-to-video requires 'data' field
await client.queue.submitAndPoll({
  model: models.video("lucy-pro-i2v"),
  prompt: "Make it cinematic",
  data: imageFile, // ✅ Required
});

// Text-to-video doesn't need 'data'
await client.queue.submitAndPoll({
  model: models.video("lucy-pro-t2v"),
  prompt: "A cat walking",
  data: imageFile, // ❌ Type error
});

Ready to start building?