Skip to main content
Try on clothing and accessories in realtime. Stream a live camera feed, describe the outfit or provide a reference image of the garment, and Lucy VTON will realistically dress the subject while preserving motion and body shape — all with minimal latency.

Quick start (Realtime)

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

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

const stream = await navigator.mediaDevices.getUserMedia({
  audio: true,
  video: {
    frameRate: model.fps,
    width: model.width,
    height: model.height,
  },
});

const client = createDecartClient({ apiKey: "your-api-key-here" });

const realtimeClient = await client.realtime.connect(stream, {
  model,
  onRemoteStream: (editedStream) => {
    document.querySelector("#video-output").srcObject = editedStream;
  },
});

// Try on with a garment image and descriptive prompt
const garmentFile = document.querySelector('input[type="file"]').files[0];
await realtimeClient.set({
  prompt: "Substitute the current top with a navy blue hoodie with a white cross logo on the chest",
  image: garmentFile,
  enhance: false,
});

// Disconnect when done
realtimeClient.disconnect();

Realtime Parameters

  • prompt — Text description of the outfit change. Use the substitute or add patterns described in the prompting guide below.
  • image — A garment reference image to guide the try-on. Supported formats: JPEG, PNG, WebP.
  • enhance — Whether to auto-enhance the prompt (default: true). Set to false when you provide detailed prompts yourself.
set() replaces the entire state — fields you omit are cleared. Always include every field you want to keep.

Using Reference Images

For the best results, provide a garment reference image paired with a descriptive prompt. This gives the model the clearest signal of what to apply.
// Best approach: reference image + descriptive prompt
await realtimeClient.set({
  prompt: "Substitute the current top with a black bomber jacket with a blue logo on the chest and a zip front",
  image: garmentFile,
  enhance: false,
});

// Reference image only — the model dresses the person to match
await realtimeClient.set({ image: garmentFile });
Reference image tips:
  • Clean garment images work best — just the clothing item, no person wearing it
  • White or plain backgrounds are ideal
  • At least 512×512 pixels — the model reproduces what it sees, so a clear image produces better results
  • If your source image shows a person wearing the garment, consider using an image editing model to extract just the clothing item first

Dynamic Outfit Changes

Switch outfits instantly during a live session — call setPrompt() or set() again at any time without reconnecting:
// Start with a casual look
realtimeClient.setPrompt("Substitute the current top with a grey crewneck sweatshirt with a large blue logo on the front");

// Switch to formal
realtimeClient.setPrompt("Substitute the current top with a navy blue blazer, worn over a light blue dress shirt");

// Try an accessory
realtimeClient.setPrompt("Add a black baseball cap with a blue logo to the person's head");

Client Token Security

In production, never expose your permanent API key (sk-*) to the browser. Instead, create a short-lived client token on your server and pass it to the frontend:
// Server: app/api/tokens/route.ts
import { createDecartClient } from "@decartai/sdk";

export async function POST() {
  const client = createDecartClient({ apiKey: process.env.DECART_API_KEY });
  const token = await client.tokens.create();
  return Response.json(token);
}
// Client: fetch token, then connect
const res = await fetch("/api/tokens", { method: "POST" });
const { apiKey } = await res.json();

const client = createDecartClient({ apiKey }); // short-lived ephemeral token
const rtClient = await client.realtime.connect(stream, { model, onRemoteStream });
Client tokens have a 10-minute TTL. Create a new token each time a user opens a try-on session. Active WebRTC sessions continue working even after the token expires. See the Client Tokens guide for details.

Prompting Guide

Lucy VTON works best with structured prompts that follow a substitute or add pattern. Focus on what needs to change — you don’t need to describe the entire scene.

Prompt Patterns

PatternWhen to useExample
SubstituteReplacing an existing garment"Substitute the current top with a red plaid flannel shirt with a relaxed fit"
AddAdding something the person isn’t wearing"Add a wide-brimmed straw hat to the person's head"
When you don’t know the person’s current outfit, use generic references: "the current top", "the current bottoms", "the current headwear".

Example Prompts

✅ "Substitute the current top with a bright red hoodie with an oversized casual fit"
✅ "Substitute the current top with a black leather bomber jacket with ribbed cuffs"
✅ "Substitute the current top with a navy blue polo shirt with a white logo on the chest"
✅ "Add a navy baseball cap with a blue logo to the person's head"
✅ "Substitute the current bottoms with dark blue slim-fit jeans"

❌ "Put a jacket on the person"        (too vague — no color, material, or fit)
❌ "Red hoodie"                         (missing action and context)
❌ "Wearing a jacket"                   (no detail about the garment)

Prompt Tips

  • Be specific — include color, material, texture, pattern, and fit. Aim for 20–30 words.
  • Describe only what you see — don’t guess details like zippers or pockets unless they’re clearly visible in the reference image.
  • One garment per prompt — combining multiple unrelated changes can produce unpredictable results.
  • Reference image + prompt — when you have a garment image, always pair it with a descriptive prompt for maximum control.
  • Use enhance: true as a fallback — the built-in enhance option can improve short or vague prompts automatically, but detailed prompts you write yourself will produce the best results.

Generating Prompts with an LLM

For user-uploaded garment images where you don’t have a pre-written prompt, you can use any vision LLM (GPT-4o-mini, Claude, Gemini) to auto-generate a descriptive prompt from the garment image:
// Send the garment image (and optionally a camera frame) to your LLM
const formData = new FormData();
formData.append("image", garmentBlob);
formData.append("personFrame", cameraFrameBlob); // optional — improves accuracy

const res = await fetch("/api/enhance-prompt", { method: "POST", body: formData });
const { prompt } = await res.json();
// → "Substitute the grey crewneck sweater with a blue and pink flame print hoodie with an oversized fit"
Sending a camera frame of the person gives the LLM context about what they’re currently wearing, so it generates more accurate prompts (e.g. “Substitute the grey sweater” instead of generic “Substitute the current top”).

Extracting Clothing from Model Photos

When users upload photos from fashion websites where a model is wearing the garment, the image contains a person and background rather than a clean garment shot. Use an image editing model to extract just the clothing item on a white background before sending it to the try-on model.

Batch API

Lucy VTON is also available as a batch/queue model for processing pre-recorded videos asynchronously. Submit a job, poll for completion, then download the result.
# Submit job
JOB_ID=$(curl -s -X POST https://api.decart.ai/v1/jobs/lucy-2.1-vton \
  -H "X-API-KEY: $DECART_API_KEY" \
  -F "data=@person.mp4" \
  -F "prompt=Substitute the current top with a red leather jacket with a zip front" \
  -F "reference_image=@garment.jpg" | jq -r '.job_id')

# Poll until completed
while true; do
  STATUS=$(curl -s -H "X-API-KEY: $DECART_API_KEY" \
    https://api.decart.ai/v1/jobs/$JOB_ID | jq -r '.status')
  echo "Status: $STATUS"
  [ "$STATUS" = "completed" ] && break
  [ "$STATUS" = "failed" ] && exit 1
  sleep 2
done

# Download result
curl -H "X-API-KEY: $DECART_API_KEY" \
  https://api.decart.ai/v1/jobs/$JOB_ID/content --output output.mp4

Batch Parameters

  • data (required) — Input video of the person to dress.
  • prompt (optional) — Text description of the outfit change. Use the substitute/add patterns above. Defaults to empty string.
  • reference_image (optional) — An image of the garment or accessory to try on.
  • resolution (optional) — Output resolution: 720p (default).
  • seed (optional) — Seed for reproducible generation (0–4294967295).
  • enhance_prompt (optional) — Whether to enhance the prompt (default: true).

Video Requirements

  • Format: MP4 (H.264 or VP8 codec)
  • Aspect Ratio: 16:9 (landscape) or 9:16 (portrait)
  • File Size: Maximum 200MB
  • Output Resolution: 720×1280 (portrait) or 1280×720 (landscape)

Next steps

Try in the Platform

Try virtual try-on in the interactive platform.

Batch API Reference

Full API documentation for the batch virtual try-on endpoint.

Streaming Best Practices

Optimize your realtime integration for the best experience.

Try-On Examples

Production-ready examples: e-commerce, digital mirror, outfit builder, and more.