# Generate Background The  is used to replace the background of any image. We offer a fast version of this feature, powered by Bria 2.3 Fast LoRA (model card on Hugging Face), which provides an optimal balance between speed and quality. This endpoint also allows replacing the background with a solid color of your choice. You can specify a hex color code (e.g., #FF5733) in the prompt to control the background color. Here are some examples: : : in a parking lot : This endpoint includes granular content moderation controls to ensure safe usage across all stages of processing: - – Validates the provided prompt and rejects requests containing unsafe or prohibited terms before processing starts. - – Scans the uploaded image and stops processing if inappropriate or restricted content is detected. - – Evaluates the generated image and blocks the response if it violates safety guidelines. Endpoint: POST /replace_background ## Header parameters: - `api_token` (string, required) API token associated with the organization. ## Request fields (application/json): - `image` (string, required) The image that you would like to remove the background from. Supported input types: - - pointing to an image file that is publicly accessible and available at the time of processing. Accepted formats: , , , . - `ref_images` (string) One or more reference images to guide the background generation. - – provide the image data directly in the request. - – provide a publicly accessible URL to the image. - – multiple images can be supplied as a list of Base64 strings or URLs. - You must provide , but not both. - Accepted formats: , , , . All provided images must be accessible and in a supported format at the time of processing. - `enhance_ref_images` (boolean) When set to true, additional logic processes the included reference image to make adjustments for optimal results. - `prompt` (string) Text description of the new scene or background for the provided image. Either ref_images or prompt has to be provided but not both. Bria currently supports prompts in English only, excluding special characters. - `refine_prompt` (boolean) When true, an additional logic takes the prompt that was included and adjusts it to achieve optimal results. - `prompt_content_moderation` (boolean) When enabled (default: ), the input prompt is moderated before processing. - The prompt is scanned for NSFW content and terms that violate Bria’s ethical guidelines. - If the prompt fails moderation, the request is blocked and the API responds with a 422 error. - `negative_prompt` (string) Elements or features that should be excluded from the generated scene. This parameter is optional and is available only when fast=false. Bria currently supports descriptions in English only. - `original_quality` (boolean) When true, the output image retains the original input image's size; otherwise, the image is scaled to 1 megapixel (1MP) while preserving its aspect ratio. - `force_background_detection` (boolean) When , forces background detection and removal, even if the original image already contains an alpha channel. Useful for refining existing foreground/background separation or ignoring unnecessary alpha channels. - `sync` (boolean) Specifies the response mode. - When (default), the request is processed asynchronously: the API immediately returns a status URL to track progress. - When , the request is processed synchronously: the API hold the connection open until the proccess is complete and then returns the final image URL in the response. - `fast` (boolean) Determines the generation mode. When true, the generation will utilize the fast mode which provides the best balance between speed and quality. When false, the regular mode will be utilized. - `visual_input_content_moderation` (boolean) When enabled, applies content moderation to input visual. Expected behavior: - Processing stops if the image fails moderation. - Returns a 422 error with details about which parameter failed. - `visual_output_content_moderation` (boolean) When enabled, applies content moderation to result visual. Expected behavior: - If the modified image fails moderation, returns a 422 error. - `seed` (integer) You can choose whether you want your generated results to be random or predictable. You can recreate the same result in the future by using the seed value of a result from the response. You can exclude this parameter if you are not interested in recreating your results. This parameter is optional. ## Response 200 fields (application/json): - `result` (object, required) - `result.image_url` (string, required) - `result.seed` (integer) - `result.refined_prompt` (string) Refined version of the input prompt. - The request included a parameter. - The request did NOT include a . - `request_id` (string, required) ## Response 202 fields (application/json): - `request_id` (string, required) - `status_url` (string, required) ## Response 400 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 401 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 403 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 404 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 415 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 422 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 429 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 460 fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required) ## Response 5XX fields (application/json): - `error` (object, required) - `error.code` (integer, required) Example: 123 - `error.message` (string, required) - `error.details` (string, required) - `request_id` (string, required)