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,
});

// Edit a video using the Queue API
const result = await client.queue.submitAndPoll({
  model: models.video("lucy-2-v2v"),
  data: videoFile,
  prompt: "Transform into anime style",
  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()

Realtime API

Realtime video streams

Queue API

Video processing

Process API

Image editing
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,
});
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 — basic (60s TTL, unrestricted)
const { apiKey, expiresAt } = await client.tokens.create();

// Or scoped to specific models with a longer TTL
const token = await client.tokens.create({
  expiresIn: 300,
  allowedModels: ["lucy_2_rt"],
});
// Send token.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";

// Realtime models
models.realtime("lucy_2_rt");         // Realtime video editing
models.realtime("mirage_v2");         // Realtime video restyling
models.realtime("live_avatar");       // Avatar animation with audio

// Video models
models.video("lucy-2-v2v");           // Video editing
models.video("lucy-restyle-v2v");     // Video restyling
models.video("lucy-motion");          // Trajectory-based motion control

// Image models
models.image("lucy-pro-i2i");         // Image editing
// Realtime models
models.realtime("lucy_v2v_720p_rt");  // Realtime video editing
models.realtime("mirage");            // Realtime video transformation

// Video models
models.video("lucy-pro-v2v");         // Lucy Edit v1

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.
// Video editing requires 'data' field
await client.queue.submitAndPoll({
  model: models.video("lucy-2-v2v"),
  prompt: "Transform into anime style",
  data: videoFile, // ✅ Required
});

// Image editing requires 'data' field
await client.process({
  model: models.image("lucy-pro-i2i"),
  prompt: "Change the background to a beach",
  data: imageFile, // ✅ Required
});

Ready to start building?

Realtime API Guide

Build realtime experiencesLearn WebRTC integration, camera handling, and how to create interactive video applications.

Queue API Guide

Video processingEdit videos, control motion, and transform videos with style transfer.

Process API Guide

Image editingEdit and transform images on-demand with synchronous processing.