Skip to content
Last updated

Working with images and video

Image inputs

Every v2 endpoint that takes an image accepts the image field in one of two forms:

FormRules
Public URLMust be reachable by Bria's servers at processing time (no authentication, no expired signed links).
Base64 stringThe raw encoded bytes only. Do not include a data:image/png;base64, prefix.

Supported formats are JPEG, PNG and WEBP. Endpoints that take several images (images, ref_images, mask) accept either form for each item.

Send a local file:

from bria_client import BriaSyncClient
from bria_client.toolkit import Image

client = BriaSyncClient()
response = client.run(
    endpoint="image/edit/remove_background",
    payload={"image": Image("product.jpg").as_bria_api_input},  # local path, URL, PIL image or numpy array
)

Image outputs

Results are delivered as a URL in result.image_url. Download and store the file yourself; result URLs are temporary. Where an endpoint offers output_type, choose png to keep transparency and jpeg for smaller files. Endpoints that preserve alpha expose preserve_alpha (default true), which keeps transparency from the input in the output.

Masks

Mask-based endpoints (/v2/image/edit/erase, /v2/image/edit/gen_fill, masked /v2/image/edit) take a mask image the same size as the input. The masked region is regenerated, so paint slightly beyond the object edge to give the model room to blend, especially around hair, glass and fabric. The endpoint page describes the mask polarity and format it expects. The Image Editing best practices guide covers how to prompt for masked regions.

Reference and multi-image requests

  • /v2/image/generate accepts a single reference image in images alongside an optional prompt.
  • /v2/image/edit accepts one to four ordered images; refer to them in the instruction as "image 1", "image 2" and so on. Masks are supported for single-image requests only.
  • /v2/image/edit/replace_background accepts reference images that guide the new background.

Structured prompts

Generation endpoints return the VGL structured_prompt used to render the image as a JSON string. Store it with the seed; sending both back reproduces the image, and adding a short prompt refines it while keeping the composition.

Video inputs

Video endpoints take a public video URL. For a local file, request a presigned upload from the Video Upload Service (POST /v2/video/upload), upload the file, and pass the returned file_url. Uploaded files are kept for one day; the SDK wraps this flow in client.upload(). For live sources use Streaming Background Removal over WebSocket instead.

Content moderation of inputs

Input images can be screened before processing with visual_input_content_moderation. Blocked inputs return 422. See Safety and transparency.