Change Background AI
1 tokenToolsReplace background with AI
Overview
Change Background AI replaces the background of an image with a new AI-generated scene based on your text prompt. The subject remains intact while the surroundings are completely replaced. Ideal for product photography, real estate images, or creative composites.
Image input
Endpoint
POST /api/v1/generatebash
curl -X POST https://roomai.com/api/v1/generate \
-H "Authorization: Bearer rai_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{"model": "changebg", ...}'Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Required | Must be "changebg". changebg |
image | string | Required | URL of the image. |
prompt | string | Required | Describe the new background (e.g. "a sunlit modern living room" or "a tropical beach at sunset"). |
format | string | Optional | Output format. Default: png |
Request Example
json
{
"model": "changebg",
"image": "https://example.com/furniture-photo.jpg",
"prompt": "a bright minimalist showroom with white walls and natural light"
}Response
Success (200)
json
{
"status": "success",
"result": {
"image_url": "https://storage.googleapis.com/...",
"model": "changebg",
"tokens_used": 1,
"processing_time_ms": 4500
}
}Error
json
{
"status": "error",
"error": {
"code": "INSUFFICIENT_TOKENS",
"message": "Not enough tokens",
"required": 1,
"balance": 0
}
}Code Examples
cURL
bash
curl -X POST https://roomai.com/api/v1/generate \
-H "Authorization: Bearer rai_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "changebg",
"image": "https://example.com/furniture-photo.jpg",
"prompt": "a bright minimalist showroom with white walls and natural light"
}'JavaScript / Node.js
javascript
const response = await fetch("https://roomai.com/api/v1/generate", {
method: "POST",
headers: {
"Authorization": "Bearer rai_live_your_api_key",
"Content-Type": "application/json",
},
body: JSON.stringify({
"model": "changebg",
"image": "https://example.com/furniture-photo.jpg",
"prompt": "a bright minimalist showroom with white walls and natural light"
}),
});
const data = await response.json();
if (data.status === "success") {
console.log("Image URL:", data.result.image_url);
console.log("Tokens used:", data.result.tokens_used);
} else {
console.error("Error:", data.error.message);
}Python
python
import requests
response = requests.post(
"https://roomai.com/api/v1/generate",
headers={
"Authorization": "Bearer rai_live_your_api_key",
"Content-Type": "application/json",
},
json={
"model": "changebg",
"image": "https://example.com/furniture-photo.jpg",
"prompt": "a bright minimalist showroom with white walls and natural light"
},
)
data = response.json()
if data["status"] == "success":
print("Image URL:", data["result"]["image_url"])
print("Tokens used:", data["result"]["tokens_used"])
else:
print("Error:", data["error"]["message"])Tips
- 1Be descriptive in your prompt — include lighting, style, and setting for the best results.
- 2Works great for product photography — place furniture in any environment.
- 3The AI automatically detects and preserves the foreground subject.