Browse all docs & guides
On this page
OPERATION & PLATFORM GUIDE

Remove image backgrounds into transparent cutouts

OpenGen exposes foreground segmentation and alpha cutout extraction under the dedicated background-remove operation. Upload a private source image via POST /v1/assets, inspect exact constraints for bria/remove-background (alpha-capable PNG or WebP output only, with no prompt field), verify route availability and published per-image rates via POST /v1/pricing/estimate, and submit with a persisted Idempotency-Key once an executable route is configured.

operation: background-removeReviewed 2026-12-02
AGENT PROMPT · PASTE INTO YOUR AGENT OR AUTO-READ
Walk me through a background-remove workflow on OpenGen (https://opengen.dev):
1. Discover background removal models with GET https://opengen.dev/v1/models?operation=background-remove (or MCP find_models with operation="background-remove").
2. Inspect exact schema limits and published pricing via GET https://opengen.dev/v1/models/bria/remove-background?operation=background-remove (or MCP get_model with id="bria/remove-background", operation="background-remove"). Note that prompt is NOT accepted and outputFormat must be "png" or "webp".
3. Upload the single private source image via POST https://opengen.dev/v1/assets (or MCP upload_asset) and confirm state="ready".
4. Run POST https://opengen.dev/v1/pricing/estimate (or MCP estimate_cost) to inspect workspaceEligibility and published per-image rates. Stop and report if routes are documented/comparison-only on the current gateway.
5. Only when an executable route is eligible and I approve the spend cap, submit once with a persisted Idempotency-Key via POST https://opengen.dev/v1/generations or MCP generate.
View raw .md ↗

OpenGen models transparent foreground segmentation under the dedicated background-remove operation. Because background removal does not use text prompts or opaque JPEG outputs, the canonical schema enforces those guardrails before any credit reservation or upstream call occurs.

1. Inspect bria/remove-background schema and pricing

BRIA RMBG 2.0 (bria/remove-background) is documented across fal ($0.018 per output image) and Replicate. Inspect its live schema and routes in one call:

curl --fail-with-body \
  "https://opengen.dev/v1/models?operation=background-remove"

curl --fail-with-body \
  "https://opengen.dev/v1/models/bria/remove-background?operation=background-remove"

Valid bria/remove-background fields

FieldRequiredAllowed values
referencesYesExactly 1 image reference ({ "type": "image", "asset": { "assetKey": "..." } }).
outputFormatOptionalAlpha-capable format only: png (default) or webp.

prompt, resolution, aspectRatio, mask, and outputFormat: "jpeg" are rejected with 400 invalid_generation.

2. Upload your private source image

Upload a workspace-private image via POST /v1/assets or reuse an earlier OpenGen generation output with { "source": "job_output", "sourceJobId": "<job-uuid>", "outputIndex": 0 }.

curl --fail-with-body \
  -X POST "https://opengen.dev/v1/assets" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Idempotency-Key: bgrem-src-$(uuidgen | tr '[:upper:]' '[:lower:]')" \
  -F "file=@./sneaker-photo.jpg;type=image/jpeg"

3. Estimate cost and route eligibility before submitting

Notice that input contains only references and outputFormat—do not include prompt. Run POST /v1/pricing/estimate first to review published pricing and workspaceEligibility.

set -eu
umask 077
if [ -e bg-remove-submission.key ]; then
  echo "Existing bg-remove-submission.key found; recover read-only via GET /v1/generations/lookup before replacing bg-remove-request.json." >&2
  exit 1
fi
rm -f bg-remove-request.json
cat <<'JSON' > bg-remove-request.json
{
  "modelId": "bria/remove-background",
  "operation": "background-remove",
  "input": {
    "references": [
      {
        "type": "image",
        "asset": {
          "assetKey": "inputs/YOUR_WORKSPACE/RETURNED_IMAGE_UUID.jpg"
        }
      }
    ],
    "outputFormat": "png"
  },
  "routeId": "fal-undisclosed/bria-remove-background",
  "billing": "managed",
  "maxCostMicros": 50000
}
JSON
chmod 600 bg-remove-request.json

# Dry-run estimate only (review selectedRouteId, recommendedMaxCostMicros, and workspaceEligibility)
curl --fail-with-body \
  -X POST "https://opengen.dev/v1/pricing/estimate" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  --data @bg-remove-request.json

Submit once after reviewing the estimate

Run this step only after reviewing the estimate output above and confirming an executable route is eligible (selectedRouteId != null, executableCandidateCount > 0, blockers: []) and confirming maxCostMicros.

set -eu
umask 077
if [ -e bg-remove-submission.key ]; then
  echo "Existing bg-remove-submission.key found; recover read-only via GET /v1/generations/lookup before creating a new submission." >&2
  exit 1
fi
RAW_UUID="$(uuidgen)"
[ -n "$RAW_UUID" ] || { echo "uuidgen failed" >&2; exit 1; }
IDEMPOTENCY_KEY="bgrem-$(printf '%s' "$RAW_UUID" | tr '[:upper:]' '[:lower:]')"
(set -C; printf '%s\n' "$IDEMPOTENCY_KEY" > bg-remove-submission.key)

curl --fail-with-body \
  -X POST "https://opengen.dev/v1/generations" \
  -H "Authorization: Bearer $OPENGEN_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Prefer: wait=20" \
  --data @bg-remove-request.json > bg-remove-receipt.json

Next steps

Supported Models

Live catalog inventory for background-remove (1 documented variant). Click any model to compare exact regional routes, privacy disclosures, and source-linked tariffs, or inspect its canonical schema directly via the single-call model endpoint.

ModelCreatorRoutesLowest published priceSingle-call API
BRIA RMBG 2.0Open weights
bria/remove-background
BRIA AI2 routes$0.018 / imageGET /v1/models/bria/remove-background?operation=background-remove