decart/lucy-2-5/realtime

Real-time, prompt-driven video editing over WebRTC. Restyle, swap backgrounds, and add or replace objects live on a webcam or streamed feed at interactive latency.
Inference
Commercial use
Partner

About

Realtime Lucy 2.5 edit over a browser WebRTC camera feed.

Signaling relay only; media flows peer-to-peer between the browser and Decart.

1. Calling the API#

Install the client#

The client provides a convenient way to interact with the model API.

npm install --save @fal-ai/client

Setup your API Key#

Set FAL_KEY as an environment variable in your runtime.

export FAL_KEY="YOUR_API_KEY"

Real-time via WebSockets#

This model has a real-time mode via websockets, this is supported via the fal.realtime client.

import { fal } from "@fal-ai/client";

const connection = fal.realtime.connect("decart/lucy-2-5/realtime", {
  onResult: (result) => {
    console.log(result);
  },
  onError: (error) => {
    console.error(error);
  },
  // Fetch short-lived JWT token from your backend
  tokenProvider: async (app) => {
    const response = await fetch("/api/fal/realtime-token", {
      method: "POST",
      headers: { "Content-Type": "application/json" },
      body: JSON.stringify({ app }),
    });
    return response.text();
  },
  tokenExpirationSeconds: 10,
});

connection.send({});

2. Authentication#

The API uses an API Key for authentication. It is recommended you set the FAL_KEY environment variable in your runtime when possible.

API Key#

In case your app is running in an environment where you cannot set environment variables, you can set the API Key manually as a client configuration.
import { fal } from "@fal-ai/client";

fal.config({
  credentials: "YOUR_FAL_KEY"
});

4. Files#

Some attributes in the API accept file URLs as input. Whenever that's the case you can pass your own URL or a Base64 data URI.

Data URI (base64)#

You can pass a Base64 data URI as a file input. The API will handle the file decoding for you. Keep in mind that for large files, this alternative although convenient can impact the request performance.

Hosted files (URL)#

You can also pass your own URLs as long as they are publicly accessible. Be aware that some hosts might block cross-site requests, rate-limit, or consider the request as a bot.

Uploading files#

We provide a convenient file storage that allows you to upload files and use them in your requests. You can upload files using the client API and use the returned URL in your requests.

import { fal } from "@fal-ai/client";

const file = new File(["Hello, World!"], "hello.txt", { type: "text/plain" });
const url = await fal.storage.upload(file);

Read more about file handling in our file upload guide.

5. Schema#

Input#

reference_image_url string

Reference image (data URI, JPEG/PNG/WebP, min 512x512) for character swap or virtual try-on. Optional for other capabilities. Default value: "null"

prompt string

Edit instruction. Drives every capability: add / replace / remove / background swap / style / VFX / change-attribute (prompt only), and character-swap / virtual-try-on (together with a reference image). Default value: "null"

enable_prompt_expansion boolean

Whether Decart should expand/enhance the prompt before applying it. Default value: true

image_url string

Live camera frame source (enables the webcam widget; unused in WebRTC mode). Default value: "null"

{
  "prompt": "Change the background to a sunlit tropical beach.",
  "enable_prompt_expansion": true
}

Output#

iceServers list<object>
type string

Default value: "null"

sdp string

Default value: "null"

error void
candidate object
{}

Other types#