换家具 API 文档#
基础 URL:
https://api.ideal.house
版本: v1
更新日期: 2026-05-21
📖 概述#
换家具 API 可对室内图片中的家具进行换风格或更换操作。提交源图片和可选风格指导,然后异步轮询任务结果。
- 创建任务 — 提交
imageUrl及可选指导,然后接收一个taskId。 - 轮询结果 — 使用
taskId查询任务状态和输出图片。
🔐 认证#
所有 API 请求必须在请求头中携带 API 密钥。
| 请求头 | 值 |
|---|---|
APIKEY | your_api_key_here |
💰 积分扣除#
[!WARNING] 🪙 1 积分 在任务成功创建时扣除。如果任务最终失败,已扣除的积分将自动退还。
积分不足时将返回错误码9051。参见积分扣除参考。
| 操作 | 扣除积分 |
|---|---|
| 换家具任务 | 1 积分 |
🎨 风格选项#
此 API 支持由 API 风格配置 端点返回的可选风格参数。
使用方式:
GET /api/v1/style/change_furniture/getStyles
| 风格分组 | 请求字段 | 说明 |
|---|---|---|
roomType | indoorTypeId | 房间类型选项 |
style | indoorStyleId | 室内风格选项 |
elements | indoorElemId | 房间元素选项。支持多个选项 ID 以逗号连接,例如 id1,id2 |
每个选项包含:
| 字段 | 说明 |
|---|---|
name | 多语言选项名称 |
id | 请求字段中传入的值 |
url | 选项的预览图片 |
📌 API 端点#
1. 创建换家具任务#
端点
POST /api/v1/changeFurniture/generate
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
Content-Type | ✅ 是 | application/json |
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
imageUrl | string | ✅ 是 | 源室内图片的 URL |
prompt | string | ❌ 可选 | 期望效果的文本指导 |
indoorTypeId | string | ❌ 可选 | 来自 roomType 风格选项的房间类型 ID |
indoorStyleId | string | ❌ 可选 | 来自 style 风格选项的室内风格 ID |
indoorElemId | string | ❌ 可选 | 来自 elements 风格选项的房间元素 ID。支持多个 ID 以逗号连接,例如 id1,id2 |
仅
imageUrl为必填项。所有其他字段均为可选。
🖼️ 图片要求: 使用 JPG/JPEG、PNG 或 WebP 格式。每张图片不得超过 20 MB,尺寸范围为 128 × 128 px 至 6,000 × 6,000 px(含边界)。超过最大像素尺寸的图片将按比例缩小以适配 6,000 × 6,000 px 后再处理。图片 URL 必须可直接被 API 服务器访问。
📥 请求示例#
cURL
curl -X POST "https://api.ideal.house/api/v1/changeFurniture/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/living-room.jpg",
"prompt": "replace the sofa with a modern warm neutral sofa",
"indoorTypeId": "Interior Design_Interior Scene_Living Room",
"indoorStyleId": "Interior_Interior Style_Popular_Modern Country",
"indoorElemId": "Interior Design_Scene Elements_Living Room_Shelving,Interior Design_Scene Elements_Living Room_Coffee Table"
}'
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class ChangeFurnitureApiExample {
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();
String requestBody = """
{
"imageUrl": "https://example.com/living-room.jpg",
"prompt": "replace the sofa with a modern warm neutral sofa",
"indoorTypeId": "Interior Design_Interior Scene_Living Room",
"indoorStyleId": "Interior_Interior Style_Popular_Modern Country",
"indoorElemId": "Interior Design_Scene Elements_Living Room_Shelving,Interior Design_Scene Elements_Living Room_Coffee Table"
}
""";
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/changeFurniture/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
BASE_URL = "https://api.ideal.house"
API_KEY = "your_api_key_here"
headers = {
"APIKEY": API_KEY,
"Content-Type": "application/json"
}
payload = {
"imageUrl": "https://example.com/living-room.jpg",
"prompt": "replace the sofa with a modern warm neutral sofa",
"indoorTypeId": "Interior Design_Interior Scene_Living Room",
"indoorStyleId": "Interior_Interior Style_Popular_Modern Country",
"indoorElemId": "Interior Design_Scene Elements_Living Room_Shelving,Interior Design_Scene Elements_Living Room_Coffee Table"
}
response = requests.post(
f"{BASE_URL}/api/v1/changeFurniture/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 BASE_URL = 'https://api.ideal.house';
const API_KEY = 'your_api_key_here';
async function createChangeFurnitureTask() {
try {
const response = await axios.post(
`${BASE_URL}/api/v1/changeFurniture/generate`,
{
imageUrl: 'https://example.com/living-room.jpg',
prompt: 'replace the sofa with a modern warm neutral sofa',
indoorTypeId: 'Interior Design_Interior Scene_Living Room',
indoorStyleId: 'Interior_Interior Style_Popular_Modern Country',
indoorElemId: 'Interior Design_Scene Elements_Living Room_Shelving,Interior Design_Scene Elements_Living Room_Coffee Table'
},
{
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);
}
}
createChangeFurnitureTask();
📤 响应#
{
"code": 0,
"message": "success",
"data": 1234567890123456789
}
| 字段 | 类型 | 说明 |
|---|---|---|
code | integer | 0 表示成功 |
message | string | 响应消息 |
data | long | 用于轮询结果的任务 ID |
2. 获取任务结果#
端点
GET /api/v1/changeFurniture/result
请求头
| 请求头 | 必填 | 说明 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
查询参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
taskId | long | ✅ 是 | 由创建端点返回的任务 ID |
📥 请求示例#
cURL
curl -X GET "https://api.ideal.house/api/v1/changeFurniture/result?taskId=1234567890123456789" \
-H "APIKEY: your_api_key_here"
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class ChangeFurnitureResultExample {
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/changeFurniture/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
while True:
response = requests.get(
f"{BASE_URL}/api/v1/changeFurniture/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)
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 pollChangeFurnitureResult(taskId) {
const headers = { APIKEY: API_KEY };
while (true) {
const response = await axios.get(
`${BASE_URL}/api/v1/changeFurniture/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;
}
await new Promise(resolve => setTimeout(resolve, 3000));
}
}
pollChangeFurnitureResult(1234567890123456789n);
📤 响应示例#
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Success",
"waitNumber": 0,
"percentage": 100,
"input": {
"imageUrl": "https://example.com/living-room.jpg",
"prompt": "replace the sofa with a modern warm neutral sofa",
"indoorTypeId": "Interior Design_Interior Scene_Living Room",
"indoorStyleId": "Interior_Interior Style_Popular_Modern Country",
"indoorElemId": "Interior Design_Scene Elements_Living Room_Shelving,Interior Design_Scene Elements_Living Room_Coffee Table"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/change_furniture_result.jpg",
"width": 1024,
"height": 1024
}
}
}
响应(任务处理中/排队中)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Processing",
"waitNumber": 1,
"percentage": 45,
"input": {
"imageUrl": "https://example.com/living-room.jpg",
"prompt": "replace the sofa with a modern warm neutral sofa"
},
"output": null
}
}
响应(任务失败)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Failed",
"waitNumber": 0,
"percentage": 0,
"input": {
"imageUrl": "https://example.com/living-room.jpg"
},
"output": null
}
}
📊 任务状态#
| 状态 | 说明 |
|---|---|
Unprocessed | 任务已创建并等待处理 |
Processing | 任务正在处理中 |
Success | 任务成功完成 |
Failed | 任务失败且未产生输出 |
每 3-5 秒 轮询一次。参见API 任务限制。
❌ 错误响应#
| 错误码 | 名称 | 说明 |
|---|---|---|
1011 | PARAM_ERROR | 请求参数错误 |
5002 | API_KEY_INVALID | 无效或缺失的 API 密钥 |
9010 | SCAN_TEXT_ERROR | 提示词审核未通过 |
9038 | PROHIBITED_CONTENT | 生成的图片包含禁止内容 |
9051 | COINS_NOT_ENOUGH | 积分不足 |
如需完整的常见错误定义,参见错误码参考。