bria/video/background-removal/realtime

Remove video backgrounds in real time with Bria’s VRMBG 3.0 model. Built for live streaming, real-time video apps, content creation, and low-latency workflows that need fast, accurate background removal.
Inference
Commercial use
Partner

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("bria/video/background-removal/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#

blur_strength integer

Background blur strength, 0-100 (used when background_type is 'blur'). Default value: 50

background_color BackgroundColorEnum

Solid background colour (used when background_type is 'color'). Default value: "Black"

Possible enum values: Black, White, Gray, Red, Green, Blue, Yellow, Cyan, Magenta, Orange

background_type BackgroundTypeEnum

How to replace the background: 'color', 'image', or 'blur'. Default value: "color"

Possible enum values: color, image, blur

image_url string

Playground webcam/video source. Media is sent over WebRTC. Default value: ""

background_image_url string

Background image URL or data URI (used when background_type is 'image'). Default value: "null"

{
  "blur_strength": 50,
  "background_color": "Black",
  "background_type": "color"
}

Output#

{}

Other types#

File#

url string* required

The URL where the file can be downloaded from.

content_type string

The mime type of the file.

file_name string

The name of the file. It will be auto-generated if not provided.

file_size integer

The size of the file in bytes.

Video#

url string* required

The URL where the file can be downloaded from.

content_type string

The mime type of the file.

file_name string

The name of the file. It will be auto-generated if not provided.

file_size integer

The size of the file in bytes.

EraseInputModel#

output_container_and_codec OutputContainerAndCodecEnum

Output container and codec. Options: mp4_h265, mp4_h264, webm_vp9, gif, mov_h264, mov_h265, mov_proresks, mkv_h264, mkv_h265, mkv_vp9, mkv_mpeg4. Default value: "mp4_h264"

Possible enum values: mp4_h265, mp4_h264, webm_vp9, gif, mov_h264, mov_h265, mov_proresks, mkv_h264, mkv_h265, mkv_vp9, mkv_mpeg4

auto_trim boolean

auto trim the video, to working duration ( 5s ) Default value: true

preserve_audio boolean

If true, audio will be preserved in the output video. Default value: true

video_url string* required

Input video to erase object from. duration must be less than 5s.

mask_video_url string* required

Input video to mask erase object from. duration must be less than 5s.

EraseByPromptInputModel#

output_container_and_codec OutputContainerAndCodecEnum

Output container and codec. Options: mp4_h265, mp4_h264, webm_vp9, gif, mov_h264, mov_h265, mov_proresks, mkv_h264, mkv_h265, mkv_vp9, mkv_mpeg4. Default value: "mp4_h264"

Possible enum values: mp4_h265, mp4_h264, webm_vp9, gif, mov_h264, mov_h265, mov_proresks, mkv_h264, mkv_h265, mkv_vp9, mkv_mpeg4

auto_trim boolean

auto trim the video, to working duration ( 5s ) Default value: true

preserve_audio boolean

If true, audio will be preserved in the output video. Default value: true

prompt string* required

Input prompt to detect object to erase

video_url string* required

Input video to erase object from. duration must be less than 5s.

EraseByKeyPointsInputModel#

output_container_and_codec OutputContainerAndCodecEnum

Output container and codec. Options: mp4_h265, mp4_h264, webm_vp9, gif, mov_h264, mov_h265, mov_proresks, mkv_h264, mkv_h265, mkv_vp9, mkv_mpeg4. Default value: "mp4_h264"

Possible enum values: mp4_h265, mp4_h264, webm_vp9, gif, mov_h264, mov_h265, mov_proresks, mkv_h264, mkv_h265, mkv_vp9, mkv_mpeg4

auto_trim boolean

auto trim the video, to working duration ( 5s ) Default value: true

preserve_audio boolean

If true, audio will be preserved in the output video. Default value: true

keypoints list<string>* required

Input keypoints [x,y] to erase or keep from the video. Format like so: {'x':100, 'y':100, 'type':'positive/negative'}

video_url string* required

Input video to erase object from. duration must be less than 5s.

bria_video-cpu_OutputRemoveBackgroundModel#

video Video* required

Video with removed background and audio.

request_id string* required

Bria request ID.

bria_video-cpu_InputRemoveBackgroundModel#

output_container_and_codec OutputContainerAndCodecEnum

Output container and codec. Options: mp4_h265, mp4_h264, webm_vp9, mov_h265, mov_proresks, mkv_h265, mkv_h264, mkv_vp9, avi_h264, gif. Default value: "webm_vp9"

Possible enum values: mp4_h265, mp4_h264, webm_vp9, mov_h265, mov_proresks, mkv_h265, mkv_h264, mkv_vp9, avi_h264, gif

preserve_audio boolean

If true, audio will be preserved in the output video. Default value: true

video_url string* required

Input video to remove background from.

background_color BackgroundColorEnum

Background color. Options: Transparent, Black, White, Gray, Red, Green, Blue, Yellow, Cyan, Magenta, Orange. Default value: "Black"

Possible enum values: Transparent, Black, White, Gray, Red, Green, Blue, Yellow, Cyan, Magenta, Orange

IceCandidate#

sdpMLineIndex integer
sdpMid string

Default value: "null"

candidate string* required

Related Models