Bria — AI Image Generation, Editing & Background Removal
Commercially safe, royalty-free image generation and editing through 20+ API endpoints. Generate from text, edit with natural language, remove backgrounds, create product shots, and build automated image pipelines.
For additional endpoint details beyond what is documented here, see the Bria API reference for agents.
When to Use This Skill
Use this skill when the user wants to:
- - 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"
- Batch/pipeline — "generate 10 product images", "process all these images", "remove backgrounds in bulk"
This skill handles the full spectrum of AI image operations. If the user mentions images, photos, visuals, or any visual content creation — use this skill.
What You Can Build
- - E-commerce product catalog — Generate product photos, remove backgrounds for transparent PNGs, place products in lifestyle scenes (kitchen, office, outdoor), create packshots with consistent style
- Landing page visuals — Generate hero images, abstract tech backgrounds, team photos, and section illustrations — all matching your brand aesthetic
- Social media content — Instagram posts (1:1), Stories/Reels (9:16), LinkedIn banners (16:9), ad creatives — batch-generate variants for A/B testing
- Marketing campaign assets — Seasonal transformations (summer→winter), restyle product shots for different markets, create localized visuals at scale
- Photo restoration pipeline — Restore old damaged photos, colorize black & white images, upscale low-res photos to 4x, enhance quality automatically
- Brand asset toolkit — Remove backgrounds from logos, blend artwork onto products (t-shirts, mugs), create consistent product photography across your entire catalog
- AI-powered design workflows — Chain operations: generate→edit→remove background→place in scene→upscale — all automated through API pipelines
Setup — Authentication
Before making any API call, you need a valid Bria access token.
Step 1: Check for existing credentials
CODEBLOCK0
If the output is READY, skip straight to making API calls — no introspection needed.
If the output is CREDENTIALS_FOUND, skip to Step 3.
If the output is NO_CREDENTIALS, proceed to Step 2.
Step 2: Authenticate via device authorization
Start the device authorization flow:
2a. Request a device code:
CODEBLOCK1
Parse the response fields:
- -
device_code — used to poll for the token (keep this, don't show to user) - INLINECODE4 — the code the user must enter (e.g.
BRIA-XXXX) - INLINECODE6 — seconds between poll attempts
2b. Show the user a single sign-in link. Tell them exactly this — nothing more:
Connect your Bria account: Click here to sign in
Your code is {user_code} — it's already filled in.
Do NOT show two links. Do NOT show the raw URL separately. Do NOT use verification_uri from the API response. Keep it to one clickable link.
2c. Poll for the token. After showing the user the code, immediately start polling. Try up to 60 times with the given interval (default 5 seconds):
CODEBLOCK2
If the output contains AUTHENTICATED, proceed to Step 3. Otherwise the code expired — start over from Step 2a.
Do not proceed with any API call until authentication is confirmed.
Step 3: Verify billing status and resolve API key
Introspect the bearer token to check billing status and obtain the real API key for Bria API calls:
CODEBLOCK3
Interpret the output:
- - If it prints
BILLING_ERROR: ... — relay the message to the user exactly as shown and stop. Do not make any API calls. - If it prints
TOKEN_EXPIRED — the session is no longer valid. Tell the user their session expired and restart from Step 2. - Otherwise,
BRIA_API_KEY now contains the real API key and is cached for future calls. Proceed to the next section.
Core Capabilities
| Need | Capability | Use Case |
|---|
| Generate images from text | FIBO Generate | Hero images, product shots, illustrations, social media images, banners |
| Edit images by text instruction |
FIBO-Edit | Change colors, modify objects, transform scenes |
| Edit image region with mask | GenFill/Erase | Precise inpainting, add/replace specific regions |
| Add/Replace/Remove objects | Text-based editing | Add vase, replace apple with pear, remove table |
| Remove background (transparent PNG) | RMBG-2.0 | Extract subjects for overlays, logos, cutouts |
| Replace/blur/erase background | Background ops | Change, blur, or remove backgrounds |
| Expand/outpaint images | Outpainting | Extend boundaries, change aspect ratios |
| Upscale image resolution | Super Resolution | Increase resolution 2x or 4x |
| Enhance image quality | Enhancement | Improve lighting, colors, details |
| Restyle images | Restyle | Oil painting, anime, cartoon, 3D render |
| Change lighting | Relight | Golden hour, spotlight, dramatic lighting |
| Change season | Reseason | Spring, summer, autumn, winter |
| Composite/blend images | Image Blending | Apply textures, logos, merge images |
| Restore old photos | Restoration | Fix old/damaged photos |
| Colorize images | Colorization | Add color to B&W, or convert to B&W |
| Sketch to photo | Sketch2Image | Convert drawings to realistic photos |
| Create product lifestyle shots | Lifestyle Shot | Place products in scenes for e-commerce |
| Integrate products into scenes | Product Integrate | Embed products at exact coordinates |
How to Call Any Endpoint
Use bria_call for all API calls. It handles URL passthrough, local file base64 encoding, JSON construction, API call, and async polling in a single function call. The API key is auto-loaded from ~/.bria/credentials.
CODEBLOCK4
Calling convention: bria_call <endpoint> <image_or_empty> [--key <json_key>] [extra JSON fields...]
- - Pass a URL, local file path, or
"" (empty) for endpoints without image input - Use
--key images when the endpoint expects an images array instead of INLINECODE18 - Extra JSON fields are appended as key-value pairs: INLINECODE19
- Returns the result image URL on success, or prints an error to stderr
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 single images.
Advanced: For precise control over generation, use the vgl skill for structured VGL JSON prompts instead of natural language.
See API Endpoints Reference for full parameter documentation on all 20+ endpoints.
Prompt Engineering Tips
- - Style: "professional product photography" vs "casual snapshot", "flat design illustration" vs "3D rendered"
- Lighting: "soft natural light", "studio lighting", "dramatic shadows"
- Background: "white studio", "gradient", "blurred office", "transparent"
- Composition: "centered", "rule of thirds", "negative space on left for text"
- Quality keywords: "high quality", "professional", "commercial grade", "4K", "sharp focus"
- Negative prompts: "blurry, low quality, pixelated", "text, watermark, logo"
Recipes by Use Case
Hero banner (16:9): "Modern tech startup workspace with developers collaborating, bright natural lighting, clean minimal aesthetic" — include "clean background" or "minimal" for text overlay space
Product photo (1:1): "Professional product photo of [item] on white studio background, soft shadows, commercial photography lighting" — then remove background for transparent PNG
Presentation visual (16:9): "Abstract visualization of data analytics, blue and purple gradient, modern corporate style, clean composition with space for text" — common themes: "abstract technology", "business collaboration", "minimalist geometric patterns"
Instagram post (1:1): INLINECODE31
Story/Reel (9:16): "Vertical product showcase of smartphone, floating in gradient background, tech aesthetic"
Additional Resources
Related Skills
- - vgl — Write structured VGL JSON prompts for precise, deterministic control over FIBO image generation
- image-utils — Classic image manipulation (resize, crop, composite, watermarks) for post-processing
Bria — AI图像生成、编辑与背景移除
通过20多个API端点实现商业安全、免版税的图像生成与编辑。从文本生成图像,用自然语言编辑,移除背景,创建产品照片,并构建自动化图像处理流水线。
有关本文档未记录的额外端点详情,请参阅Bria智能体API参考。
何时使用此技能
当用户想要以下操作时使用此技能:
- - 生成图像 — 创建一张...的图像、给我做个横幅、生成一张主图、我需要一张产品照片
- 编辑图像 — 更换背景、让它看起来像冬天、在桌子上加一个花瓶、移除这个人
- 移除/替换背景 — 让背景透明、抠出产品、替换为工作室背景
- 产品摄影 — 创建一张生活场景照、把这个产品放到厨房场景中、电商产品展示图
- 增强/变换 — 放大这张图片、提高分辨率、重新风格化为油画、改变光照
- 批量/流水线 — 生成10张产品图片、处理所有这些图片、批量移除背景
此技能涵盖AI图像操作的全方位需求。如果用户提到图像、照片、视觉或任何视觉内容创作——请使用此技能。
你可以构建什么
- - 电商产品目录 — 生成产品照片,移除背景生成透明PNG,将产品放入生活场景(厨房、办公室、户外),创建风格一致的产品展示图
- 落地页视觉素材 — 生成主图、抽象科技背景、团队照片和章节插图——全部匹配你的品牌美学
- 社交媒体内容 — Instagram帖子(1:1)、故事/短视频(9:16)、LinkedIn横幅(16:9)、广告创意——批量生成变体用于A/B测试
- 营销活动素材 — 季节性变换(夏季→冬季),为不同市场重新风格化产品照片,大规模创建本地化视觉素材
- 照片修复流水线 — 修复老旧损坏照片,黑白照片上色,低分辨率照片放大4倍,自动提升质量
- 品牌素材工具包 — 移除Logo背景,将艺术作品融合到产品上(T恤、马克杯),为整个产品目录创建一致的产品摄影
- AI驱动设计工作流 — 链式操作:生成→编辑→移除背景→放入场景→放大——全部通过API流水线自动化
设置 — 身份验证
在进行任何API调用之前,你需要一个有效的Bria访问令牌。
第1步:检查现有凭据
bash
if [ -f ~/.bria/credentials ]; then
BRIAACCESSTOKEN=$(grep ^access_token= $HOME/.bria/credentials | cut -d= -f2-)
BRIAAPIKEY=$(grep ^api_token= $HOME/.bria/credentials | cut -d= -f2-)
fi
if [ -z $BRIAACCESSTOKEN ]; then
echo NO_CREDENTIALS
elif [ -n $BRIAAPIKEY ]; then
echo READY
else
echo CREDENTIALS_FOUND
fi
如果输出为READY,直接跳转到进行API调用——无需内省。
如果输出为CREDENTIALS_FOUND,跳转到第3步。
如果输出为NO_CREDENTIALS,继续执行第2步。
第2步:通过设备授权进行身份验证
启动设备授权流程:
2a. 请求设备码:
bash
DEVICE_RESPONSE=$(curl -s -X POST https://engine.prod.bria-api.com/v2/auth/device/authorize \
-H Content-Type: application/json)
echo $DEVICE_RESPONSE
解析响应字段:
- - devicecode — 用于轮询令牌(保留此值,不要展示给用户)
- usercode — 用户必须输入的代码(例如BRIA-XXXX)
- interval — 轮询尝试之间的秒数
2b. 向用户展示一个单一的登录链接。 只告诉用户以下内容——不要多说:
连接你的Bria账户: 点击此处登录
你的代码是 {user_code} — 已自动填写。
不要显示两个链接。不要单独显示原始URL。不要使用API响应中的verification_uri。只保留一个可点击的链接。
2c. 轮询令牌。 向用户展示代码后,立即开始轮询。按给定的间隔(默认5秒)最多尝试60次:
bash
for i in $(seq 1 60); do
TOKEN_RESPONSE=$(curl -s -X POST https://engine.prod.bria-api.com/v2/auth/token \
-d granttype=urn:ietf:params:oauth:grant-type:devicecode \
-d devicecode=$DEVICECODE)
ACCESSTOKEN=$(printf %s $TOKENRESPONSE | sed -n s/.access_token : \([^]\).*/\1/p)
if [ -n $ACCESS_TOKEN ]; then
BRIAACCESSTOKEN=$ACCESS_TOKEN
REFRESHTOKEN=$(printf %s $TOKENRESPONSE | sed -n s/.refresh_token : \([^]\).*/\1/p)
mkdir -p ~/.bria
printf accesstoken=%s\nrefreshtoken=%s\n $BRIAACCESSTOKEN $REFRESH_TOKEN > $HOME/.bria/credentials
echo AUTHENTICATED
break
fi
sleep 5
done
如果输出包含AUTHENTICATED,继续执行第3步。否则代码已过期——从第2a步重新开始。
在确认身份验证完成之前,不要进行任何API调用。
第3步:验证计费状态并解析API密钥
内省Bearer令牌以检查计费状态并获取用于Bria API调用的真实API密钥:
bash
INTROSPECT=$(curl -s -X POST https://engine.prod.bria-api.com/v2/auth/token/introspect \
-d token=$BRIAACCESSTOKEN)
BILLINGSTATUS=$(printf %s $INTROSPECT | sed -n s/.billingstatus : \([^]\).*/\1/p)
if [ $BILLING_STATUS = blocked ]; then
BILLINGMSG=$(printf %s $INTROSPECT | sed -n s/.billingmessage : \([^]\).*/\1/p)
echo BILLINGERROR: $BILLINGMSG
fi
ACTIVE=$(printf %s $INTROSPECT | sed -n s/.active : \([^,}]\).*/\1/p | tr -d )
if [ $ACTIVE = false ]; then
# 清除过期令牌,以便重新认证从新开始(凭据文件在第2c步重新创建)
printf > $HOME/.bria/credentials
echo TOKEN_EXPIRED
fi
BRIAAPIKEY=$(printf %s $INTROSPECT | sed -n s/.api_token : \([^]\).*/\1/p)
if [ -n $BRIAAPIKEY ]; then
grep -v ^api_token= $HOME/.bria/credentials > $HOME/.bria/credentials.tmp 2>/dev/null || true
printf apitoken=%s\n $BRIAAPI_KEY >> $HOME/.bria/credentials.tmp
mv $HOME/.bria/credentials.tmp $HOME/.bria/credentials
fi
解释输出:
- - 如果打印BILLINGERROR: ... — 将消息原样转达给用户并停止。不要进行任何API调用。
- 如果打印TOKENEXPIRED — 会话已失效。告知用户会话已过期并从第2步重新开始。
- 否则,BRIAAPIKEY现在包含真实的API密钥并已缓存供后续调用使用。继续执行下一部分。
核心能力
| 需求 | 能力 | 使用场景 |
|---|
| 从文本生成图像 | FIBO Generate | 主图、产品照片、插图、社交媒体图片、横幅 |
| 通过文本指令编辑图像 |
FIBO-Edit | 更改颜色、修改对象、变换场景 |
| 使用遮罩编辑图像区域 | GenFill/Erase | 精确修复、添加/替换特定区域 |
| 添加/替换/移除对象 | 基于文本的编辑 | 添加