Skip to main content
Get your first successful Decart result in under 5 minutes.

Prerequisites

export DECART_API_KEY="your-api-key-here"
Using an AI coding agent? Run npx skills add https://docs.platform.decart.ai to teach it Decart’s APIs, or connect the MCP server for live docs search.

Pick your first integration path

1) Install SDK

npm install @decartai/sdk

2) Connect camera + model

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

const model = models.realtime("lucy-2");

// Request camera access — will throw if the user denies permission
let stream: MediaStream;
try {
  stream = await navigator.mediaDevices.getUserMedia({
    video: { frameRate: model.fps, width: model.width, height: model.height },
    audio: true,
  });
} catch (err) {
  if (err instanceof DOMException && err.name === "NotAllowedError") {
    console.error("Camera permission denied. Please allow camera access and reload.");
  } else {
    console.error("Could not access camera:", err);
  }
  throw err;
}

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

const realtimeClient = await client.realtime.connect(stream, {
  model,
  onRemoteStream: (remoteStream) => {
    document.getElementById("output").srcObject = remoteStream;
  },
  onError: (err) => {
    console.error("Realtime connection error:", err);
  },
  onDisconnect: (reason) => {
    console.log("Disconnected:", reason);
  },
  initialState: {
    prompt: { text: "Substitute the character in the video with an anime-style hero with spiky silver hair and glowing blue eyes.", enhance: true },
  },
});

// Switch to a different transformation on the fly
await realtimeClient.setPrompt("Substitute the character in the video with a Renaissance oil painting portrait.");

Expected result

You should see the transformed stream rendered in your output video element.
Common issues:
  • Camera permission denied — the browser will prompt the user. If denied, getUserMedia throws a NotAllowedError.
  • No camera found — throws a NotFoundError. Check that a video device is connected.
  • Connection drops — the onDisconnect callback fires. In production, implement reconnection logic.
For browser/mobile production setups, use Client Tokens instead of exposing a permanent API key.

Next steps

Lucy 2 Realtime

Start with the flagship realtime model for character transformation.

JavaScript Realtime SDK

Full WebRTC integration guide.

Client Tokens

Secure browser/mobile realtime authentication.

Models

Pick the best model for your use case.

Examples Hub

Browse official examples and realtime-first starter projects.

Use Cases

See complete realtime and batch product patterns.