# Working with images and video

## Image inputs

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

| Form | Rules |
|  --- | --- |
| Public URL | Must be reachable by Bria's servers at processing time (no authentication, no expired signed links). |
| Base64 string | The 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:

Python SDK
```python
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
)
```

TypeScript SDK
```typescript
import { BriaClient, Image } from "@bria-ai/client";

const client = new BriaClient();
const response = await client.run("image/edit/remove_background", {
  image: new Image("product.jpg").asBriaApiInput, // local path, URL, Buffer or Uint8Array
});
```

cURL
```bash
curl -X POST https://engine.prod.bria-api.com/v2/image/edit/remove_background \
  -H "api_token: $BRIA_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d "{\"image\": \"$(base64 -w0 product.jpg)\"}"
```

## 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](/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](/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](/local-video-upload-service) (`POST /v2/video/upload`), upload the file, and pass the returned `file_url`. Uploaded files are kept for one day; both SDKs wrap this flow in `client.upload()`. For live sources use [Streaming Background Removal](/streaming-rmbg) 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](/safety).