Dress subjects with a prompt or a garment reference image
import { createDecartClient, models } from "@decartai/sdk";
const model = models.realtime("lucy-vton-3.5");
// Get user's camera stream with model specifications
const stream = await navigator.mediaDevices.getUserMedia({
audio: true,
video: {
frameRate: model.fps,
width: model.width,
height: model.height,
}
});
// Create a client
const client = createDecartClient({
apiKey: "your-api-key-here"
});
// Connect and try the garment on the live stream
const realtimeClient = await client.realtime.connect(stream, {
model,
mirror: "auto",
onRemoteStream: (transformedStream) => {
const videoElement = document.querySelector("#video-output");
videoElement.srcObject = transformedStream;
}
});
// set() replaces the full state — prompt + garment image atomically
await realtimeClient.set({
prompt: "Wearing a black bomber jacket with a blue logo on the chest",
image: "https://example.com/garment.png",
});
// Switch the garment on the fly
await realtimeClient.set({
prompt: "Wearing a red leather jacket",
image: "https://example.com/red-jacket.png",
});
// Disconnect when done
realtimeClient.disconnect();
promptOptionalDescribe the clothing or accessory to try on.
imageOptionalReference image of the garment or accessory. Passed via initialState.image or realtimeClient.set({ image }).
streamRequiredVideo stream (WebRTC)
promptstringNoDescribe the clothing or accessory to try on.imageFileNoReference image of the garment or accessory. Passed via initialState.image or realtimeClient.set({ image }).streamFileYesVideo stream (WebRTC)Dress subjects live with a prompt or a garment reference image
Swap outfits, accessories, and garments on a live video stream. Upload a reference image of the garment, describe it with a prompt, or do both — Lucy Virtual Try-On dresses the subject as they move, holding the fit, drape, and body shape stable frame to frame with zero perceptible latency.
Video models are charged per second of generated video. Final cost depends on video duration and selected resolution.