Bria — AI Image Generation, Editing & Background Removal
Commercially safe, royalty-free image generation and editing through 20+ API endpoints.
For additional endpoint details, see the Bria API reference for agents.
When to Use This Skill
- Generate images — "create an image of...", "make me a banner", "generate a hero image", "I need a product photo"
- Edit images — "change the background", "make it look like winter", "add a vase to the table", "remove the person"
- Remove/replace backgrounds — "make the background transparent", "cut out the product", "replace with a studio background"
- Product photography — "create a lifestyle shot", "place this product in a kitchen scene", "e-commerce packshot"
- Enhance/transform — "upscale this image", "make it higher resolution", "restyle as oil painting", "change the lighting"
Setup — Authentication
Step 1: Check for existing credentials
if [ -f ~/.bria/credentials ]; then
BRIA_ACCESS_TOKEN=$(grep '^access_token=' "$HOME/.bria/credentials" | cut -d= -f2-)
BRIA_API_KEY=$(grep '^api_token=' "$HOME/.bria/credentials" | cut -d= -f2-)
fi
if [ -z "$BRIA_ACCESS_TOKEN" ]; then
echo "NO_CREDENTIALS"
elif [ -n "$BRIA_API_KEY" ]; then
echo "READY"
else
echo "CREDENTIALS_FOUND"
fi
READY → skip to making API calls
CREDENTIALS_FOUND → skip to Step 3
NO_CREDENTIALS → proceed to Step 2
Step 2: Authenticate via device flow
Source the auth helper and run bria_auth:
source ~/.agents/skills/bria-ai/references/code-examples/bria_auth.sh
bria_auth
bria_auth will print SIGN_IN_URL=... and USER_CODE=.... Show the user exactly this — nothing more:
Connect your Bria account: Click here to sign in
Your code is {USER_CODE} — it's already filled in.
Then wait; bria_auth polls automatically and prints AUTHENTICATED when done.
If it prints an error, the code expired — run bria_auth again.
Do not proceed with any API call until authentication is confirmed.
Step 3: Verify billing status and resolve API key
source ~/.agents/skills/bria-ai/references/code-examples/bria_auth.sh
bria_introspect
Interpret output:
BILLING_ERROR: ... — relay the message to the user verbatim and stop. Do not make any API calls.
TOKEN_EXPIRED — tell the user their session expired and restart from Step 2.
READY — BRIA_API_KEY is now cached in ~/.bria/credentials. Proceed.
Decision Tree — Which Endpoint to Use
Transparent PNG / cutout / remove background?
→ /v2/image/edit/remove_background
Generate image from scratch (text → image)?
→ /v2/image/generate
Edit existing image with text instruction?
→ /v2/image/edit (use --key images)
Combine 2-4 images — outfit, product, logo, style, or background from one into another?
→ /v2/image/edit (--key images, then one --image per extra reference)
Change / replace / blur background?
→ /v2/image/edit/replace_background (prompt: "blur" or describe new bg)
Place product in a lifestyle scene?
→ /v1/product/lifestyle_shot_by_text
Upscale / increase resolution?
→ /v2/image/edit/increase_resolution (scale: 2 or 4)
Anything else (restyle, relight, reseason, restore, colorize, sketch, blend, outpaint)?
→ See references/capabilities.md for the full endpoint list
How to Call Any Endpoint
source ~/.agents/skills/bria-ai/references/code-examples/bria_client.sh
# Generate (no image input)
RESULT=$(bria_call /v2/image/generate "" '"prompt": "your description", "aspect_ratio": "16:9", "sync": true')
# Remove background
RESULT=$(bria_call /v2/image/edit/remove_background "/path/to/local/image.png")
# Replace background
RESULT=$(bria_call /v2/image/edit/replace_background "https://example.com/img.jpg" '"prompt": "sunset beach"')
# Edit image (uses images array — pass --key images)
RESULT=$(bria_call /v2/image/edit "/path/to/image.png" --key images '"instruction": "make it look warmer"')
# Edit with reference images — each --image adds the next one, in order
RESULT=$(bria_call /v2/image/edit "https://example.com/man.jpg" --key images \
--image "https://example.com/santa.png" \
'"instruction": "dress the man in image 1 in the santa outfit from image 2"')
# Upscale
RESULT=$(bria_call /v2/image/edit/increase_resolution "https://example.com/img.jpg" '"desired_increase": 4')
# Lifestyle shot
RESULT=$(bria_call /v1/product/lifestyle_shot_by_text "/path/to/product.png" '"scene_description": "modern kitchen countertop"')
echo "$RESULT"
Calling convention: bria_call <endpoint> <image_or_empty> [--key <json_key>] [extra JSON fields...]
- Pass a URL, local file path, or
"" for endpoints without image input
- Use
--key images when the endpoint expects an images array instead of image
- Add
--image <url_or_path> once per extra reference image (--key images, up to 4 in total).
Order is preserved: the positional image is "image 1", the first --image is "image 2", …
- Returns the result image URL on success, or prints an error to stderr
Editing with several images (2-4): put the image being edited first, references after it, and
address them by position — "dress the man in image 1 in the santa outfit from image 2". Say what
each reference contributes, in plain prose. Single-image edits need no positional wording.
Generation options: Aspect ratios 1:1, 16:9, 4:3, 9:16, 3:4. Resolution 1MP (default) or 4MP (more detail, +30s). Pass "sync": true for a single generated image. Editing endpoints are the other way round —
they answer with a status_url you poll, and "sync": true on an edit fails with a gateway
timeout.
Advanced: For precise control over generation, use the vgl skill for structured VGL JSON prompts.
Common Failures
bria_call returns empty / no URL → BRIA_API_KEY was not set. Run Step 3 (bria_introspect) to cache it.
- Async job times out → Some endpoints take 60–90s. If
bria_call reports a timeout, retry once; the job may have been queued.
- ERROR 401 → API key is stale. Delete
~/.bria/credentials and re-authenticate from Step 2.
BILLING_ERROR → Relay message to user verbatim, do not retry API calls.
- Local file not found → Pass the absolute path;
bria_client.sh handles base64 encoding automatically.
/v2/image/edit returns wrong result → Confirm --key images flag is present; this endpoint requires the images array format.
Resources
- Capabilities & Prompt Recipes — Full endpoint table, use-case recipes, and prompt engineering tips
- API Endpoints Reference — Complete parameter documentation for all 20+ endpoints
- Shell Client (bria_client.sh) —
bria_call helper: auth, base64, JSON, polling
- Auth Helper (bria_auth.sh) —
bria_auth and bria_introspect functions
- Full API docs for agents (llms.txt) — Agent-ready Bria API reference
Related Skills
- vgl — Structured VGL JSON prompts for precise, deterministic control over FIBO image generation
- image-utils — Classic image manipulation (resize, crop, composite, watermarks) for post-processing
1---2name: bria-ai-23description: Bria.ai image API — generate from text prompts, edit with natural language, remove backgrounds for transparent PNGs, and create product lifestyle shots. Authenticates via OAuth device flow, caches credentials in ~/.bria/credentials, calls 20+ endpoints. Commercially safe, royalty-free. Triggers on: remove background, transparent PNG, cutout, generate image, create banner, edit photo, product photography, upscale, restyle, inpainting, outpainting, lifestyle shot, background replacement, object removal, photo restoration.4license: MIT5---67# Bria — AI Image Generation, Editing & Background Removal89Commercially safe, royalty-free image generation and editing through 20+ API endpoints.1011For additional endpoint details, see the [Bria API reference for agents](https://docs.bria.ai/llms.txt).1213## When to Use This Skill1415- **Generate images** — "create an image of...", "make me a banner", "generate a hero image", "I need a product photo"16- **Edit images** — "change the background", "make it look like winter", "add a vase to the table", "remove the person"17- **Remove/replace backgrounds** — "make the background transparent", "cut out the product", "replace with a studio background"18- **Product photography** — "create a lifestyle shot", "place this product in a kitchen scene", "e-commerce packshot"19- **Enhance/transform** — "upscale this image", "make it higher resolution", "restyle as oil painting", "change the lighting"2021---2223## Setup — Authentication2425### Step 1: Check for existing credentials2627```bash28if [ -f ~/.bria/credentials ]; then29 BRIA_ACCESS_TOKEN=$(grep '^access_token=' "$HOME/.bria/credentials" | cut -d= -f2-)30 BRIA_API_KEY=$(grep '^api_token=' "$HOME/.bria/credentials" | cut -d= -f2-)31fi32if [ -z "$BRIA_ACCESS_TOKEN" ]; then33 echo "NO_CREDENTIALS"34elif [ -n "$BRIA_API_KEY" ]; then35 echo "READY"36else37 echo "CREDENTIALS_FOUND"38fi39```4041- `READY` → skip to making API calls42- `CREDENTIALS_FOUND` → skip to Step 343- `NO_CREDENTIALS` → proceed to Step 24445### Step 2: Authenticate via device flow4647Source the auth helper and run `bria_auth`:4849```bash50source ~/.agents/skills/bria-ai/references/code-examples/bria_auth.sh51bria_auth52```5354`bria_auth` will print `SIGN_IN_URL=...` and `USER_CODE=...`. Show the user exactly this — nothing more:5556> **Connect your Bria account:** [Click here to sign in]({SIGN_IN_URL})57> Your code is **{USER_CODE}** — it's already filled in.5859Then wait; `bria_auth` polls automatically and prints `AUTHENTICATED` when done.6061If it prints an error, the code expired — run `bria_auth` again.6263**Do not proceed with any API call until authentication is confirmed.**6465### Step 3: Verify billing status and resolve API key6667```bash68source ~/.agents/skills/bria-ai/references/code-examples/bria_auth.sh69bria_introspect70```7172Interpret output:73- `BILLING_ERROR: ...` — relay the message to the user verbatim and **stop**. Do not make any API calls.74- `TOKEN_EXPIRED` — tell the user their session expired and restart from Step 2.75- `READY` — `BRIA_API_KEY` is now cached in `~/.bria/credentials`. Proceed.7677---7879## Decision Tree — Which Endpoint to Use8081```82Transparent PNG / cutout / remove background?83 → /v2/image/edit/remove_background8485Generate image from scratch (text → image)?86 → /v2/image/generate8788Edit existing image with text instruction?89 → /v2/image/edit (use --key images)9091Combine 2-4 images — outfit, product, logo, style, or background from one into another?92 → /v2/image/edit (--key images, then one --image per extra reference)9394Change / replace / blur background?95 → /v2/image/edit/replace_background (prompt: "blur" or describe new bg)9697Place product in a lifestyle scene?98 → /v1/product/lifestyle_shot_by_text99100Upscale / increase resolution?101 → /v2/image/edit/increase_resolution (scale: 2 or 4)102103Anything else (restyle, relight, reseason, restore, colorize, sketch, blend, outpaint)?104 → See references/capabilities.md for the full endpoint list105```106107---108109## How to Call Any Endpoint110111```bash112source ~/.agents/skills/bria-ai/references/code-examples/bria_client.sh113114# Generate (no image input)115RESULT=$(bria_call /v2/image/generate "" '"prompt": "your description", "aspect_ratio": "16:9", "sync": true')116117# Remove background118RESULT=$(bria_call /v2/image/edit/remove_background "/path/to/local/image.png")119120# Replace background121RESULT=$(bria_call /v2/image/edit/replace_background "https://example.com/img.jpg" '"prompt": "sunset beach"')122123# Edit image (uses images array — pass --key images)124RESULT=$(bria_call /v2/image/edit "/path/to/image.png" --key images '"instruction": "make it look warmer"')125126# Edit with reference images — each --image adds the next one, in order127RESULT=$(bria_call /v2/image/edit "https://example.com/man.jpg" --key images \128 --image "https://example.com/santa.png" \129 '"instruction": "dress the man in image 1 in the santa outfit from image 2"')130131# Upscale132RESULT=$(bria_call /v2/image/edit/increase_resolution "https://example.com/img.jpg" '"desired_increase": 4')133134# Lifestyle shot135RESULT=$(bria_call /v1/product/lifestyle_shot_by_text "/path/to/product.png" '"scene_description": "modern kitchen countertop"')136137echo "$RESULT"138```139140**Calling convention:** `bria_call <endpoint> <image_or_empty> [--key <json_key>] [extra JSON fields...]`141- Pass a URL, local file path, or `""` for endpoints without image input142- Use `--key images` when the endpoint expects an `images` array instead of `image`143- Add `--image <url_or_path>` once per extra reference image (`--key images`, up to 4 in total).144 Order is preserved: the positional image is "image 1", the first `--image` is "image 2", …145- Returns the result image URL on success, or prints an error to stderr146147**Editing with several images (2-4):** put the image being edited first, references after it, and148address them by position — *"dress the man in image 1 in the santa outfit from image 2"*. Say what149each reference contributes, in plain prose. Single-image edits need no positional wording.150151**Generation options:** Aspect ratios `1:1`, `16:9`, `4:3`, `9:16`, `3:4`. Resolution `1MP` (default) or `4MP` (more detail, +30s). Pass `"sync": true` for a single generated image. Editing endpoints are the other way round —152they answer with a `status_url` you poll, and `"sync": true` on an edit fails with a gateway153timeout.154155> **Advanced**: For precise control over generation, use the **vgl** skill for structured VGL JSON prompts.156157---158159## Common Failures160161- **`bria_call` returns empty / no URL** → `BRIA_API_KEY` was not set. Run Step 3 (`bria_introspect`) to cache it.162- **Async job times out** → Some endpoints take 60–90s. If `bria_call` reports a timeout, retry once; the job may have been queued.163- **ERROR 401** → API key is stale. Delete `~/.bria/credentials` and re-authenticate from Step 2.164- **`BILLING_ERROR`** → Relay message to user verbatim, do not retry API calls.165- **Local file not found** → Pass the absolute path; `bria_client.sh` handles base64 encoding automatically.166- **`/v2/image/edit` returns wrong result** → Confirm `--key images` flag is present; this endpoint requires the images array format.167168---169170## Resources171172- **[Capabilities & Prompt Recipes](references/capabilities.md)** — Full endpoint table, use-case recipes, and prompt engineering tips173- **[API Endpoints Reference](references/api-endpoints.md)** — Complete parameter documentation for all 20+ endpoints174- **[Shell Client (bria_client.sh)](references/code-examples/bria_client.sh)** — `bria_call` helper: auth, base64, JSON, polling175- **[Auth Helper (bria_auth.sh)](references/code-examples/bria_auth.sh)** — `bria_auth` and `bria_introspect` functions176- **[Full API docs for agents (llms.txt)](https://docs.bria.ai/llms.txt)** — Agent-ready Bria API reference177178## Related Skills179180- **vgl** — Structured VGL JSON prompts for precise, deterministic control over FIBO image generation181- **image-utils** — Classic image manipulation (resize, crop, composite, watermarks) for post-processing