物体移除 API 文档#
基础 URL:
https://api.ideal.house
版本: v1
更新时间: 2026-03-06
📖 概述#
物体移除 API 允许您使用 AI 从室内图像中移除不需要的物体或家具。它支持两种模式:
single_furniture— 通过提供标记目标区域的遮罩图像来移除特定家具。AI 会智能填充被移除区域,生成干净自然的视觉效果。whole_house— 无需遮罩,自动移除整个房间的所有家具。
工作流程为异步,包含两个步骤:
- 创建任务 — 提交源图像、遮罩和参数,然后获得一个
taskId。 - 轮询结果 — 使用
taskId查询任务状态并获取结果图像。
🔐 身份验证#
所有 API 请求必须使用 API Key 进行认证。
将您的 API Key 包含在请求头中:
| 头部 | 值 |
|---|---|
APIKEY | your_api_key_here |
⚠️ 请妥善保管您的 API Key。 切勿将其暴露在客户端代码或公开仓库中。
💰 积分扣减#
[!WARNING] 🪙 每个任务在创建成功时将从您的账户扣除 1 积分。 如果任务最终失败,已扣除的积分将自动退还到您的账户。
积分不足将返回错误码9051。📄 参见积分扣减说明。
🖼️ 遮罩图像格式#
遮罩图像定义了要从源图像中移除的区域。
遮罩规则:
| 颜色 | 含义 |
|---|---|
| ⬛ 黑色 | 要移除的区域(需要擦除的物体/区域) |
| ⬜ 白色 | 要保留的区域(需要保留的背景) |
⚠️ 遮罩图像必须与源图像具有相同的尺寸(
imageUrl)。
遮罩示例:
遮罩中的黑色区域标记需要移除的家具;白色区域是需要保留的背景。
📌 API 端点#
1. 创建物体移除任务#
创建一个新的 AI 物体移除任务,并返回用于轮询的唯一 taskId。
端点
POST /api/v1/objectRemover/generate
请求头部
| 头部 | 是否必需 | 说明 |
|---|---|---|
APIKEY | ✅ 必需 | 您的 API 认证密钥 |
Content-Type | ✅ 必需 | application/json |
请求体
| 字段 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
imageUrl | string | ✅ 必需 | 源图像的 URL |
emptyType | string | ✅ 必需 | 移除模式。枚举值:whole_house、single_furniture。控制 AI 如何填充被移除区域 |
maskUrl | string | ⚠️ 当 emptyType=single_furniture 时必需 | 遮罩图像的 URL。黑色区域将被移除;白色区域将被保留。仅在 single_furniture 模式下生效 |
maskBase64 | string | ⚠️ 当 emptyType=single_furniture 时必需 | Base64 编码的遮罩图像(建议使用 PNG 格式)。maskUrl 的替代方案。仅在 single_furniture 模式下生效 |
⚠️ 按模式的遮罩要求:
single_furniture— 必须提供maskUrl和maskBase64中的至少一个。若两者均提供,则以maskUrl为准。whole_house— 遮罩字段会被忽略。AI 会自动移除整个房间的所有家具。
🖼️ 图像要求: 源图像和遮罩图像须使用 JPG/JPEG、PNG 或 WebP 格式。每张图像大小不得超过 20 MB,尺寸范围为 128 × 128 px 至 6,000 × 6,000 px(含边界)。超出最大像素尺寸的图像将被自动按比例缩小以适应 6,000 × 6,000 px 后再进行处理。图像 URLs 必须能够被 API 服务器直接访问。Base64 遮罩同样受解码图像限制约束,且不得包含 data-URL 前缀。
Empty Type 选项
| 值 | 是否需要遮罩 | 说明 |
|---|---|---|
single_furniture | ✅ 必需 | 移除遮罩定义的特定家具,并自然填充该区域 |
whole_house | ❌ 不需要 | 自动移除整个房间的所有家具,无需遮罩 |
📥 请求示例#
cURL
# single_furniture mode — mask required (using maskUrl)
curl -X POST "https://api.ideal.house/api/v1/objectRemover/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"emptyType": "single_furniture",
"maskUrl": "https://example.com/mask.png"
}'
# single_furniture mode — mask required (using maskBase64)
curl -X POST "https://api.ideal.house/api/v1/objectRemover/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"emptyType": "single_furniture",
"maskBase64": "iVBORw0KGgoAAAANSUhEUgAA..."
}'
# whole_house mode — no mask needed
curl -X POST "https://api.ideal.house/api/v1/objectRemover/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"emptyType": "whole_house"
}'
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Base64;
public class ObjectRemoverApiExample {
private static final String BASE_URL = "https://api.ideal.house";
private static final String API_KEY = "your_api_key_here";
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
// Option 1: Use maskUrl
String requestBody = """
{
"imageUrl": "https://example.com/room.jpg",
"maskUrl": "https://example.com/mask.png",
"emptyType": "single_furniture"
}
""";
// Option 2: Use maskBase64 (encode local mask file)
// byte[] maskBytes = Files.readAllBytes(Path.of("/path/to/mask.png"));
// String maskBase64 = Base64.getEncoder().encodeToString(maskBytes);
// String requestBody = """
// {
// "imageUrl": "https://example.com/room.jpg",
// "maskBase64": "%s",
// "emptyType": "single_furniture"
// }
// """.formatted(maskBase64);
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/objectRemover/generate")
.addHeader("APIKEY", API_KEY)
.addHeader("Content-Type", "application/json")
.post(RequestBody.create(requestBody, MediaType.parse("application/json")))
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println("Response: " + response.body().string());
}
}
}
Python (requests)
import requests
import base64
BASE_URL = "https://api.ideal.house"
API_KEY = "your_api_key_here"
headers = {
"APIKEY": API_KEY,
"Content-Type": "application/json"
}
# Option 1: Use maskUrl
payload = {
"imageUrl": "https://example.com/room.jpg",
"maskUrl": "https://example.com/mask.png",
"emptyType": "single_furniture"
}
# Option 2: Use maskBase64 (encode local mask file)
# with open("/path/to/mask.png", "rb") as f:
# mask_base64 = base64.b64encode(f.read()).decode("utf-8")
# payload = {
# "imageUrl": "https://example.com/room.jpg",
# "maskBase64": mask_base64,
# "emptyType": "single_furniture"
# }
response = requests.post(
f"{BASE_URL}/api/v1/objectRemover/generate",
headers=headers,
json=payload
)
data = response.json()
task_id = data.get("data")
print(f"Task ID: {task_id}")
Node.js (axios)
const axios = require('axios');
const fs = require('fs');
const BASE_URL = 'https://api.ideal.house';
const API_KEY = 'your_api_key_here';
async function createObjectRemoverTask() {
try {
// Option 1: Use maskUrl
const payload = {
imageUrl: 'https://example.com/room.jpg',
maskUrl: 'https://example.com/mask.png',
emptyType: 'single_furniture'
};
// Option 2: Use maskBase64 (encode local mask file)
// const maskBuffer = fs.readFileSync('/path/to/mask.png');
// const maskBase64 = maskBuffer.toString('base64');
// const payload = {
// imageUrl: 'https://example.com/room.jpg',
// maskBase64: maskBase64,
// emptyType: 'single_furniture'
// };
const response = await axios.post(
`${BASE_URL}/api/v1/objectRemover/generate`,
payload,
{
headers: {
'APIKEY': API_KEY,
'Content-Type': 'application/json'
}
}
);
const taskId = response.data.data;
console.log('Task ID:', taskId);
return taskId;
} catch (error) {
console.error('Error:', error.response?.data || error.message);
}
}
createObjectRemoverTask();
📤 响应#
成功响应
{
"code": 0,
"message": "success",
"data": 1234567890123456789
}
| 字段 | 类型 | 说明 |
|---|---|---|
code | integer | 0 表示成功 |
message | string | 响应消息 |
data | long | 用于轮询结果的唯一任务 ID |
2. 获取任务结果#
获取之前创建的物体移除任务的当前状态和输出。
端点
GET /api/v1/objectRemover/result
请求头部
| 头部 | 是否必需 | 说明 |
|---|---|---|
APIKEY | ✅ 必需 | 您的 API 认证密钥 |
查询参数
| 参数 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
taskId | long | ✅ 必需 | 创建任务端点返回的任务 ID |
📥 请求示例#
cURL
curl -X GET "https://api.ideal.house/api/v1/objectRemover/result?taskId=1234567890123456789" \
-H "APIKEY: your_api_key_here"
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class ObjectRemoverResultExample {
private static final String BASE_URL = "https://api.ideal.house";
private static final String API_KEY = "your_api_key_here";
public static void main(String[] args) throws IOException {
OkHttpClient client = new OkHttpClient();
long taskId = 1234567890123456789L;
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/objectRemover/result?taskId=" + taskId)
.addHeader("APIKEY", API_KEY)
.get()
.build();
try (Response response = client.newCall(request).execute()) {
System.out.println("Response: " + response.body().string());
}
}
}
Python (requests)
import requests
import time
BASE_URL = "https://api.ideal.house"
API_KEY = "your_api_key_here"
headers = {
"APIKEY": API_KEY
}
task_id = 1234567890123456789
# Poll until task is complete
while True:
response = requests.get(
f"{BASE_URL}/api/v1/objectRemover/result",
headers=headers,
params={"taskId": task_id}
)
data = response.json()
result = data.get("data", {})
status = result.get("status")
print(f"Status: {status}, Progress: {result.get('percentage')}%, Queue: {result.get('waitNumber')}")
if status in ("Success", "Failed"):
break
time.sleep(3) # Poll every 3 seconds
if status == "Success":
print("Result URL:", result["output"]["resultUrl"])
else:
print("Task ended with status:", status)
Node.js (axios)
const axios = require('axios');
const BASE_URL = 'https://api.ideal.house';
const API_KEY = 'your_api_key_here';
async function pollResult(taskId) {
const headers = { 'APIKEY': API_KEY };
while (true) {
const response = await axios.get(
`${BASE_URL}/api/v1/objectRemover/result`,
{
headers,
params: { taskId }
}
);
const result = response.data.data;
const { status, percentage, waitNumber } = result;
console.log(`Status: ${status} | Progress: ${percentage}% | Queue: ${waitNumber}`);
if (['Success', 'Failed'].includes(status)) {
if (status === 'Success') {
console.log('Result URL:', result.output.resultUrl);
console.log('Size:', result.output.width, 'x', result.output.height);
} else {
console.log('Task ended with status:', status);
}
break;
}
// Wait 3 seconds before next poll
await new Promise(resolve => setTimeout(resolve, 3000));
}
}
pollResult(1234567890123456789n);
📤 响应#
成功响应(任务已完成)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Success",
"waitNumber": 0,
"percentage": 100,
"input": {
"imageUrl": "https://example.com/room.jpg",
"maskUrl": "https://example.com/mask.png",
"emptyType": "single_furniture"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/object_remover_result.jpg",
"width": 1024,
"height": 1024
}
}
}
响应(任务处理中/队列中)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Processing",
"waitNumber": 1,
"percentage": 50,
"input": {
"imageUrl": "https://example.com/room.jpg",
"maskUrl": "https://example.com/mask.png",
"emptyType": "single_furniture"
},
"output": null
}
}
响应(任务失败)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Failed",
"waitNumber": 0,
"percentage": 0,
"input": {
"imageUrl": "https://example.com/room.jpg",
"maskUrl": "https://example.com/mask.png",
"emptyType": "single_furniture"
},
"output": null
}
}
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
id | long | 任务唯一标识符 |
status | string | 当前任务状态(参见任务状态) |
waitNumber | integer | 队列中排在前面的任务数量(0 表示正在处理) |
percentage | integer | 任务完成百分比(0–100) |
input | object | 任务的原始输入参数 |
input.imageUrl | string | 源图像 URL |
input.maskUrl | string | 遮罩图像 URL(如通过 maskUrl 提供) |
input.emptyType | string | 使用的移除模式(single_furniture 或 whole_house) |
output | object | 生成结果(仅当 status 为 Success 时可用) |
output.resultUrl | string | 指向物体移除结果图像的 URL |
output.width | integer | 输出宽度(像素) |
output.height | integer | 输出高度(像素) |
📊 任务状态#
| 状态 | 说明 |
|---|---|
Unprocessed | 任务已创建但尚未开始 |
Processing | 任务正在处理中 |
Success | 任务成功完成——输出可用 |
Failed | 任务因错误而失败 |
每 3-5 秒轮询一次。参见API 任务限制。
❌ 错误响应#
所有错误响应共享相同的 JSON 结构:
{
"code": 5002,
"message": "Invalid API Key",
"data": null
}
错误码参考#
| 错误码 | 名称 | 说明 | 建议操作 |
|---|---|---|---|
1001 | FAILED | 请求失败(通用错误) | 查看 message 字段获取具体错误详情 |
1003 | INTERNAL_ERROR | 内部服务器错误 | 稍后重试;若持续出现请联系支持团队 |
1011 | PARAM_ERROR | 请求参数错误 — e.g.,maskUrl 和 maskBase64 均缺失 | 确保提供至少一项遮罩字段 |
5002 | API_KEY_INVALID | API Key 无效或缺失 | 确保 APIKEY 头部存在且值正确 |
9038 | PROHIBITED_CONTENT | 生成的输出图像包含违禁内容 | 调整提示/风格/输入后重试 |
9051 | COINS_NOT_ENOUGH | 积分/金币不足 | 充值账户积分后重试 |
📄 常见 API 错误码完整列表,请参阅错误码参考。
