Ideal House
跳转到主要内容

物体移除 API 文档#

基础 URL: https://api.ideal.house
版本: v1
更新时间: 2026-03-06


📖 概述#

物体移除 API 允许您使用 AI 从室内图像中移除不需要的物体或家具。它支持两种模式:

  • single_furniture — 通过提供标记目标区域的遮罩图像来移除特定家具。AI 会智能填充被移除区域,生成干净自然的视觉效果。
  • whole_house — 无需遮罩,自动移除整个房间的所有家具。

工作流程为异步,包含两个步骤:

  1. 创建任务 — 提交源图像、遮罩和参数,然后获得一个 taskId
  2. 轮询结果 — 使用 taskId 查询任务状态并获取结果图像。

🔐 身份验证#

所有 API 请求必须使用 API Key 进行认证。

将您的 API Key 包含在请求头中:

头部
APIKEYyour_api_key_here

⚠️ 请妥善保管您的 API Key。 切勿将其暴露在客户端代码或公开仓库中。


💰 积分扣减#

[!WARNING] 🪙 每个任务在创建成功时将从您的账户扣除 1 积分。 如果任务最终失败,已扣除的积分将自动退还到您的账户。
积分不足将返回错误码 9051。📄 参见积分扣减说明


🖼️ 遮罩图像格式#

遮罩图像定义了要从源图像中移除的区域。

遮罩规则:

颜色含义
黑色要移除的区域(需要擦除的物体/区域)
白色要保留的区域(需要保留的背景)

⚠️ 遮罩图像必须与源图像具有相同的尺寸imageUrl)。

遮罩示例:

遮罩示例

遮罩中的黑色区域标记需要移除的家具;白色区域是需要保留的背景。


📌 API 端点#


1. 创建物体移除任务#

创建一个新的 AI 物体移除任务,并返回用于轮询的唯一 taskId

端点

纯文本
POST /api/v1/objectRemover/generate

请求头部

头部是否必需说明
APIKEY✅ 必需您的 API 认证密钥
Content-Type✅ 必需application/json

请求体

字段类型是否必需说明
imageUrlstring✅ 必需源图像的 URL
emptyTypestring✅ 必需移除模式。枚举值:whole_housesingle_furniture。控制 AI 如何填充被移除区域
maskUrlstring⚠️ 当 emptyType=single_furniture 时必需遮罩图像的 URL。黑色区域将被移除;白色区域将被保留。仅在 single_furniture 模式下生效
maskBase64string⚠️ 当 emptyType=single_furniture 时必需Base64 编码的遮罩图像(建议使用 PNG 格式)。maskUrl 的替代方案。仅在 single_furniture 模式下生效

⚠️ 按模式的遮罩要求:

  • single_furniture必须提供 maskUrlmaskBase64 中的至少一个。若两者均提供,则以 maskUrl 为准。
  • whole_house — 遮罩字段会被忽略。AI 会自动移除整个房间的所有家具。

🖼️ 图像要求: 源图像和遮罩图像须使用 JPG/JPEG、PNG 或 WebP 格式。每张图像大小不得超过 20 MB,尺寸范围为 128 × 128 px6,000 × 6,000 px(含边界)。超出最大像素尺寸的图像将被自动按比例缩小以适应 6,000 × 6,000 px 后再进行处理。图像 URLs 必须能够被 API 服务器直接访问。Base64 遮罩同样受解码图像限制约束,且不得包含 data-URL 前缀。


Empty Type 选项

是否需要遮罩说明
single_furniture✅ 必需移除遮罩定义的特定家具,并自然填充该区域
whole_house❌ 不需要自动移除整个房间的所有家具,无需遮罩

📥 请求示例#

cURL
bash
# 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)
java
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)
python
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)
javascript
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();

📤 响应#

成功响应

json
{
  "code": 0,
  "message": "success",
  "data": 1234567890123456789
}
字段类型说明
codeinteger0 表示成功
messagestring响应消息
datalong用于轮询结果的唯一任务 ID

2. 获取任务结果#

获取之前创建的物体移除任务的当前状态和输出。

端点

纯文本
GET /api/v1/objectRemover/result

请求头部

头部是否必需说明
APIKEY✅ 必需您的 API 认证密钥

查询参数

参数类型是否必需说明
taskIdlong✅ 必需创建任务端点返回的任务 ID

📥 请求示例#

cURL
bash
curl -X GET "https://api.ideal.house/api/v1/objectRemover/result?taskId=1234567890123456789" \
  -H "APIKEY: your_api_key_here"
Java (OkHttp)
java
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)
python
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)
javascript
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);

📤 响应#

成功响应(任务已完成)

json
{
  "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
    }
  }
}

响应(任务处理中/队列中)

json
{
  "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
  }
}

响应(任务失败)

json
{
  "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
  }
}

响应字段

字段类型说明
idlong任务唯一标识符
statusstring当前任务状态(参见任务状态
waitNumberinteger队列中排在前面的任务数量(0 表示正在处理)
percentageinteger任务完成百分比(0–100
inputobject任务的原始输入参数
input.imageUrlstring源图像 URL
input.maskUrlstring遮罩图像 URL(如通过 maskUrl 提供)
input.emptyTypestring使用的移除模式(single_furniturewhole_house
outputobject生成结果(仅当 statusSuccess 时可用)
output.resultUrlstring指向物体移除结果图像的 URL
output.widthinteger输出宽度(像素)
output.heightinteger输出高度(像素)

📊 任务状态#

状态说明
Unprocessed任务已创建但尚未开始
Processing任务正在处理中
Success任务成功完成——输出可用
Failed任务因错误而失败

3-5 秒轮询一次。参见API 任务限制


❌ 错误响应#

所有错误响应共享相同的 JSON 结构:

json
{
  "code": 5002,
  "message": "Invalid API Key",
  "data": null
}

错误码参考#

错误码名称说明建议操作
1001FAILED请求失败(通用错误)查看 message 字段获取具体错误详情
1003INTERNAL_ERROR内部服务器错误稍后重试;若持续出现请联系支持团队
1011PARAM_ERROR请求参数错误 — e.g.,maskUrlmaskBase64 均缺失确保提供至少一项遮罩字段
5002API_KEY_INVALIDAPI Key 无效或缺失确保 APIKEY 头部存在且值正确
9038PROHIBITED_CONTENT生成的输出图像包含违禁内容调整提示/风格/输入后重试
9051COINS_NOT_ENOUGH积分/金币不足充值账户积分后重试

📄 常见 API 错误码完整列表,请参阅错误码参考