Bria Generate Background Serverless API
Transform images through advanced background editing and generative content creation for diverse applications.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/bria-replace-background"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "ref_images": "sample text",
12 "enhance_ref_images": true,
13 "prompt": "In a parking lot",
14 "refine_prompt": true,
15 "prompt_content_moderation": true,
16 "negative_prompt": "no cars",
17 "original_quality": false,
18 "force_background_detection": false,
19 "fast": false,
20 "visual_input_content_moderation": false,
21 "visual_output_content_moderation": false,
22 "seed": 1234
23}
24
25response = requests.post(url, headers=headers, json=data)
26
27if response.status_code == 200:
28 result = response.json()
29 print(json.dumps(result, indent=2))
30else:
31 print(f"Error: {response.status_code}")
32 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/bria-replace-background"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "ref_images": "sample text",
12 "enhance_ref_images": true,
13 "prompt": "In a parking lot",
14 "refine_prompt": true,
15 "prompt_content_moderation": true,
16 "negative_prompt": "no cars",
17 "original_quality": false,
18 "force_background_detection": false,
19 "fast": false,
20 "visual_input_content_moderation": false,
21 "visual_output_content_moderation": false,
22 "seed": 1234
23}
24
25response = requests.post(url, headers=headers, json=data)
26
27if response.status_code == 200:
28 result = response.json()
29 print(json.dumps(result, indent=2))
30else:
31 print(f"Error: {response.status_code}")
32 print(response.text)API Endpoint
https://api.segmind.com/v1/bria-replace-backgroundParameters
imagerequiredstring | stringThe primary image for processing; Keep quality high for best output. For example, use URLs like 'https://yourimage.com/main.jpg'.
Option 1optionalstring (uri)Option 2optionalstringenhance_ref_imagesoptionalbooleanImproves reference image quality; Set true for enhanced images, false for original.
truefastoptionalbooleanSpeeds up processing; use true for quick outputs.
falseforce_background_detectionoptionalbooleanDetects background with transparency; true improves control.
falsenegative_promptoptionalstringExcludes unwanted elements; specify like 'no cars'.
"no cars"original_qualityoptionalbooleanRetains original resolution; true for high-res, false for faster results.
falsepromptoptionalstringDefines desired scene; use clear, simple language like 'sunny beach with palm trees'.
"In a parking lot"prompt_content_moderationoptionalbooleanEnsures prompt safety; always true for moderated content.
trueref_imagesoptionalstring (uri)Reference images for guidance; Use similar style images such as 'https://examples.com/ref1.jpg', 'https://examples.com/ref2.jpg'.
nullrefine_promptoptionalbooleanRefines complex descriptions; true for detailed prompts, false for straightforward.
trueseedoptionalintegerSets result reproducibility; use specific numbers like '1234'.
1234visual_input_content_moderationoptionalbooleanChecks input for safety; enable during public demos.
falsevisual_output_content_moderationoptionalbooleanEnsures output safety; turn on when unsure of results.
falseResponse Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out