{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":["tabs","tab"]},"type":"markdown"},"seo":{"title":"Self-host RMBG 2.0","description":"Generate and edit images and video with Bria's Fibo models through a REST API, Python and TypeScript SDKs, MCP server and agent skills. Licensed training data, controllable output, provenance on every result.","siteUrl":"https://docs.bria.ai","image":"/assets/bria-social-card.5f3c59395e7b5efa776984c64ef9cb0956b1d651f45b7ebf9502122a66054f35.db81178d.png","llmstxt":{"hide":false,"title":"Bria API documentation","description":"Bria's developer platform: controllable, commercially safe visual generative AI (images and video) as a REST API, Python and TypeScript SDKs, MCP server and agent skills.","details":{"path":"_llmstxt-details.md"},"sections":[{"title":"Getting started","description":"First call, authentication, async jobs and webhooks, rate limits, inputs.","includeFiles":["index.md","whats-new/fibo-2.md","getting-started/quickstart.md","getting-started/authentication.md","getting-started/async-requests.md","status.yaml","getting-started/rate-limits-and-errors.md","getting-started/working-with-images.md","getting-started/asset-retention.md"]},{"title":"Integrate","description":"Python SDK, TypeScript SDK, MCP server, agent skills, and machine-readable docs for agents.","includeFiles":["integration-methods/python-sdk.md","integration-methods/typescript-sdk.md","MCP-authentication.md","integration-methods/bria-skill.md","integration-methods/for-ai-agents.md"]},{"title":"Concepts","description":"Platform map, VGL and the Fibo models, safety, best practices.","includeFiles":["products-overview.md","VGL.md","safety.md","best-practices-overview.md","image-generation-best-practices.md","image-editing-best-practices.md","product-shots-best-practices.md"]},{"title":"Image Generation","description":"Generate images from text, reference images or structured (VGL) prompts with Fibo 2.","includeFiles":["image-generation-overview.md","image-generation.yaml"]},{"title":"Image Editing","description":"Instruction-based editing plus specialized endpoints for backgrounds, erasing, fill, expansion, upscaling and style.","includeFiles":["image-editing-overview.md","image-editing.yaml"]},{"title":"Product Shot Editing","description":"Cutouts, packshots, shadows, lifestyle scenes, product integration, holding, virtual try-on, automotive.","includeFiles":["product-shot-overview.md","product-shot-editing.yaml"]},{"title":"Video Editing","description":"Background removal (REST or real-time streaming), erasing, upscaling and masks for video; local video upload.","includeFiles":["video-editing-overview.md","local-video-upload-service.md","streaming-rmbg.md","video-editing.yaml"]},{"title":"Ads","description":"Finished ads as input. Ad Delayer turns one into editable layers (the guide holds the layer document contract); Ad Resize produces it at other sizes with the layout redone.","includeFiles":["ads-overview.md","ads.yaml"]},{"title":"Trust and provenance","description":"Public verification of Bria provenance, and attribution of outputs to licensed training data.","includeFiles":["trust-and-provenance-overview.md","visual-verification-overview.md","visual-verification.yaml","enterprise/attribution.md","bria-attribution-service.yaml"]},{"title":"Self-hosting","description":"Run licensed Bria models on your own GPUs. Buy a per-model license, install with Bria Studio or the Python library, run, and handle license errors.","includeFiles":["self-hosted/quickstart.md","self-hosted/overview.md","self-hosted/best-practices.md","self-hosted/fibo-2.md","self-hosted/rmbg-2.md"]},{"title":"Enterprise","description":"Run Bria in your own cloud or on-premises.","includeFiles":["enterprise/deployment-options.md"]}],"excludeFiles":["_llmstxt-details.md","README.md"]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"self-host-rmbg-20","__idx":0},"children":["Self-host RMBG 2.0"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Run ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/image-editing/editing/background-remove"},"children":["RMBG 2.0"]}," background removal on your own hardware with a self-hosted license. This guide installs the model, downloads its weights from Bria, and removes the background from a first image."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"requirements","__idx":1},"children":["Requirements"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["An active ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["RMBG 2.0"]}," self-hosted license (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://platform.bria.ai/licensing/pricing"},"children":["pricing"]},")"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["One of your organization's ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/getting-started/authentication"},"children":["API keys"]}]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["A machine with an NVIDIA GPU and Python 3.10 or newer"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["For the manual install: ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["curl"]}," and ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["jq"]},", and network access to the Bria Engine, AWS CodeArtifact and Bria's weights CDN (no Hugging Face account)"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"1-get-a-license","__idx":2},"children":["1. Get a license"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Buy an RMBG 2.0 license on the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://platform.bria.ai/licensing/pricing"},"children":["pricing page"]},". You manage it, and see the installation steps, on the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://platform.bria.ai/organization-management/licensing"},"children":["Licenses tab"]}," in the Console."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"2-install","__idx":3},"children":["2. Install"]},{"$$mdtype":"Tag","name":"Tabs","attributes":{"size":"medium"},"children":[{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Bria Studio (recommended)","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":[{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/self-hosted/quickstart"},"children":["Bria Studio"]}," installs the package, downloads the weights, and runs a test for you:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"npx @bria-ai/studio\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pick ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["RMBG 2.0"]}," when Studio lists your licensed models. It installs ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["remove_bg"]}," into a virtual environment at ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.bria/venvs/rmbg-2.0"]},", downloads the weights, and removes a sample background to confirm the setup."]}]},{"$$mdtype":"Tag","name":"TabItemFragment","attributes":{"label":"Manual (Docker, CI)","disable":false},"children":[{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Exchange your API key for a short-lived registry credential, then install the package:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"export BRIA_API_TOKEN=\"<your-bria-api-token>\"\n\nCA=$(curl -s \"https://engine.prod.bria-api.com/v2/outpost/access/code_artifact?repository=bria-remove-bg\" \\\n      -H \"api_token: $BRIA_API_TOKEN\" | jq -r '.result.authorization_token')\n\npip install --upgrade \"remove_bg>=0.5.0\" \\\n  --extra-index-url \"https://aws:$CA@bria-300465780738.d.codeartifact.us-east-1.amazonaws.com/pypi/bria-remove-bg/simple/\"\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Weights download on first load (",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"#3-run-it"},"children":["step 3"]},"). In a Dockerfile, exchange and install at build time, pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["BRIA_API_TOKEN"]}," at runtime, and mount ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.bria"]}," to cache weights:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"dockerfile","header":{"controls":{"copy":{}}},"source":"FROM nvidia/cuda:12.4.1-runtime-ubuntu22.04\nRUN apt-get update && apt-get install -y python3-pip curl jq && rm -rf /var/lib/apt/lists/*\n\nARG BRIA_API_TOKEN\nRUN CA=$(curl -s \"https://engine.prod.bria-api.com/v2/outpost/access/code_artifact?repository=bria-remove-bg\" \\\n      -H \"api_token: $BRIA_API_TOKEN\" | jq -r '.result.authorization_token') \\\n && pip install --upgrade \"remove_bg>=0.5.0\" \\\n      --extra-index-url \"https://aws:$CA@bria-300465780738.d.codeartifact.us-east-1.amazonaws.com/pypi/bria-remove-bg/simple/\"\n","lang":"dockerfile"},"children":[]}]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"3-run-it","__idx":4},"children":["3. Run it"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Run from the environment the model is installed in. If you used Studio, activate the venv it created:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"bash","header":{"controls":{"copy":{}}},"source":"source ~/.bria/venvs/rmbg-2.0/bin/activate\n","lang":"bash"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Then load the model with your API key and remove a background. On first load ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["setup()"]}," checks your license and downloads the weights to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["~/.bria/models"]},"; later runs reuse them."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"python","header":{"controls":{"copy":{}}},"source":"import os\nfrom remove_bg import RemoveBG, RemoveBGConfig, RemoveBGInput\n\n# Reads BRIA_API_TOKEN; checks the license and downloads the weights on first load.\npipe = RemoveBG(config=RemoveBGConfig(compile_model=False, api_token=os.environ[\"BRIA_API_TOKEN\"]))\npipe.setup()\n\nresult = pipe.execute([RemoveBGInput(image=\"https://bria-test-images.s3.us-east-1.amazonaws.com/strawberry.jpg\")])[0]\nresult.image.save(\"cutout.png\")  # RGBA cutout with a transparent background\n\npipe.cleanup()  # free the GPU when you are done\n","lang":"python"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Pass a URL or local path to ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemoveBGInput.image"]},". Inputs and outputs stay on your machine — only a small ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/enterprise/attribution"},"children":["attribution"]}," vector is sent to Bria."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"errors-and-troubleshooting","__idx":5},"children":["Errors and troubleshooting"]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["No license for RMBG 2.0"]}]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Your account holds no active RMBG 2.0 license, so the install stops before anything downloads. Buy or renew it on the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://platform.bria.ai/organization-management/licensing"},"children":["Licenses tab"]},"."]}]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["LicenseError"]}," when the model starts"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The license was cancelled or ended. Open the ",{"$$mdtype":"Tag","name":"a","attributes":{"href":"https://platform.bria.ai/organization-management/licensing"},"children":["Licenses tab"]}," — the error links straight to it. A card retry (",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["past_due"]},") stays active."]}]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["The model won't load and asks for an API token"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["No ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["BRIA_API_TOKEN"]}," is set. Set it, or pass ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["RemoveBGConfig(api_token=\"...\")"]},"."]}]},{"$$mdtype":"Tag","name":"details","attributes":{},"children":[{"$$mdtype":"Tag","name":"summary","attributes":{},"children":[{"$$mdtype":"Tag","name":"strong","attributes":{},"children":[{"$$mdtype":"Tag","name":"code","attributes":{},"children":["WeightsError"]}," during download"]}]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The download was interrupted. Run again — it resumes where it stopped."]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"usage-and-billing","__idx":6},"children":["Usage and billing"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Self-hosted runs are counted against your RMBG 2.0 license and shown in ",{"$$mdtype":"Tag","name":"strong","attributes":{},"children":["Usage & billing"]}," in the Console, tagged as self-hosted. See ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"/self-hosted/overview#licensing-and-usage"},"children":["Self-hosted models"]}," for how licensing and billing work across models."]}]},"headings":[{"value":"Self-host RMBG 2.0","id":"self-host-rmbg-20","depth":1},{"value":"Requirements","id":"requirements","depth":2},{"value":"1. Get a license","id":"1-get-a-license","depth":2},{"value":"2. Install","id":"2-install","depth":2},{"value":"3. Run it","id":"3-run-it","depth":2},{"value":"Errors and troubleshooting","id":"errors-and-troubleshooting","depth":2},{"value":"Usage and billing","id":"usage-and-billing","depth":2}],"frontmatter":{"title":"Self-host RMBG 2.0","description":"Run Bria's RMBG 2.0 background removal on your own GPUs with a self-hosted license. Install with Bria Studio or manually (Docker, CI), run a first image, and handle license errors.","seo":{"title":"Self-host RMBG 2.0"}},"lastModified":"2026-10-20T14:36:32.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/self-hosted/rmbg-2","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}