家具试摆 API 文档#
基础 URL:
https://api.ideal.house
版本: v1
更新日期: 2026-03-09
📖 概述#
家具试摆 API 允许您使用 AI 将家具虚拟放置到房间场景中。您提供一张房间图片和一份家具列表(每件包含图片和产品 ID),AI 会将家具无缝合成到场景之中。该工作流程为异步模式,包含两个步骤:
- 创建任务 — 提交您的房间图片和家具列表,然后获取一个
taskId。 - 轮询结果 — 使用
taskId查询任务状态并获取生成的图片。
📌 注意: 目前仅支持
creative模式。
🔐 认证#
所有 API 请求必须使用 API Key 进行认证。
将您的 API Key 包含在请求头中:
| 请求头 | 值 |
|---|---|
APIKEY | your_api_key_here |
⚠️ 请妥善保管您的 API Key。 请勿将其暴露在客户端代码或公开仓库中。
💰 积分扣除#
[!WARNING] 🪙 任务创建成功后,将根据所选的
modelType扣除积分。如果任务最终失败,所扣除的积分将自动退还至您的账户。
积分不足将返回错误码9051。📄 请参阅 积分扣除参考。
模型(modelType) | 扣除积分 |
|---|---|
Base | 3 积分 |
Pro | 10 积分 |
📌 API 端点#
1. 创建家具试摆任务#
创建一个新的 AI 家具试摆任务,并返回一个用于轮询的唯一 taskId。
端点
POST /api/v1/furnitureTryOn/generate
请求头
| 请求头 | 是否必填 | 描述 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
Content-Type | ✅ 是 | application/json |
请求体
| 字段 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
imageUrl | string | ✅ 是 | 将被放置家具的房间场景图片的 URL |
furnitureList | array | ✅ 是 | 要放置到场景中的家具列表。最多 6 件物品。 参见 家具商品对象 |
prompt | string | ❌ 可选 | 自定义文本提示,用于进一步引导摆放和样式 |
modelType | string | ❌ 可选 | 模型质量类型。枚举值:Base、Pro。默认为 Base |
🛋️ 家具商品对象#
furnitureList 中的每一项必须是包含以下字段的对象:
| 字段 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
imageUrl | string | ✅ 是 | 家具商品图片的 URL(建议使用透明或干净背景的图片) |
⚠️
furnitureList最多可包含 6 件物品。
🖼️ 图片要求: 房间图片和每件家具图片必须使用 JPG/JPEG、PNG 或 WebP 格式。每张大小不超过 20 MB,尺寸范围为 128 × 128 px 至 6,000 × 6,000 px(含边界值)。超出最大像素尺寸的图片将按比例缩小以适配 6,000 × 6,000 px 后再进行处理。图片 URLs 必须能被 API 服务器直接访问。
示例
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
},
{
"imageUrl": "https://example.com/table.png"
}
]
模型类型
| 值 | 描述 |
|---|---|
Base | 默认值。 速度与质量均衡 |
Pro | 更高质量的输出,处理速度较慢 |
📥 请求示例#
cURL
# Basic request (Base model)
curl -X POST "https://api.ideal.house/api/v1/furnitureTryOn/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/living-room.jpg",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
},
{
"imageUrl": "https://example.com/coffee-table.png"
}
],
"prompt": "modern minimalist style"
}'
# Pro model
curl -X POST "https://api.ideal.house/api/v1/furnitureTryOn/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/living-room.jpg",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
}
],
"prompt": "Scandinavian interior with warm lighting",
"modelType": "Pro"
}'
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class FurnitureTryOnApiExample {
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",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
},
{
"imageUrl": "https://example.com/coffee-table.png"
}
],
"prompt": "modern minimalist style",
"modelType": "Base"
}
""";
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/furnitureTryOn/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",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
},
{
"imageUrl": "https://example.com/coffee-table.png"
}
],
"prompt": "modern minimalist style",
"modelType": "Base"
}
# Pro model example:
# payload = {
# "imageUrl": "https://example.com/living-room.jpg",
# "furnitureList": [
# {
# "imageUrl": "https://example.com/sofa.png"
# }
# ],
# "prompt": "Scandinavian interior with warm lighting",
# "modelType": "Pro"
# }
response = requests.post(
f"{BASE_URL}/api/v1/furnitureTryOn/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 createFurnitureTryOnTask() {
try {
const response = await axios.post(
`${BASE_URL}/api/v1/furnitureTryOn/generate`,
{
imageUrl: 'https://example.com/living-room.jpg',
furnitureList: [
{
imageUrl: 'https://example.com/sofa.png'
},
{
imageUrl: 'https://example.com/coffee-table.png'
}
],
prompt: 'modern minimalist style',
modelType: 'Base'
// Pro model:
// modelType: 'Pro'
},
{
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);
}
}
createFurnitureTryOnTask();
📤 响应#
成功响应
{
"code": 0,
"message": "success",
"data": 1234567890123456789
}
| 字段 | 类型 | 描述 |
|---|---|---|
code | integer | 0 表示成功 |
message | string | 响应消息 |
data | long | 用于轮询结果的唯一任务 ID |
2. 获取任务结果#
获取之前创建的家具试摆任务的当前状态和输出。
端点
GET /api/v1/furnitureTryOn/result
请求头
| 请求头 | 是否必填 | 描述 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
查询参数
| 参数 | 类型 | 是否必填 | 描述 |
|---|---|---|---|
taskId | long | ✅ 是 | 从创建任务端点返回的任务 ID |
📥 请求示例#
cURL
curl -X GET "https://api.ideal.house/api/v1/furnitureTryOn/result?taskId=1234567890123456789" \
-H "APIKEY: your_api_key_here"
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class FurnitureTryOnResultExample {
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/furnitureTryOn/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/furnitureTryOn/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":
output = result["output"]
print("Result URL:", output["resultUrl"])
print("Matched Items:", output.get("items", []))
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/furnitureTryOn/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('Matched Items:', result.output.items);
} 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/living-room.jpg",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
},
{
"imageUrl": "https://example.com/coffee-table.png"
}
],
"prompt": "modern minimalist style",
"modelType": "Base"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/furniture_try_on_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",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
}
],
"prompt": "modern minimalist style",
"modelType": "Base"
},
"output": null
}
}
响应(任务失败)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Failed",
"waitNumber": 0,
"percentage": 0,
"input": {
"imageUrl": "https://example.com/living-room.jpg",
"furnitureList": [
{
"imageUrl": "https://example.com/sofa.png"
}
],
"modelType": "Base"
},
"output": null
}
}
响应字段
| 字段 | 类型 | 描述 |
|---|---|---|
id | long | 任务唯一标识符 |
status | string | 当前任务状态(参见 任务状态) |
waitNumber | integer | 队列中排在任务前面的数量(0 表示正在处理中) |
percentage | integer | 任务完成百分比(0–100) |
input | object | 任务的原始输入参数 |
input.imageUrl | string | 房间场景图片 URL |
input.furnitureList | array | 提交的家具列表(最多 6 件物品) |
input.furnitureList[].imageUrl | string | 家具商品图片 URL |
input.prompt | string | 自定义文本提示(如有提供) |
input.modelType | string | 使用的模型类型 |
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.、imageUrl 或 furnitureList 缺失,或 furnitureList 超过 6 件物品 | 确保同时提供 imageUrl 和 furnitureList,且均非空,包含不超过 6 件物品 |
5002 | API_KEY_INVALID | 无效或缺失的 API Key | 确保 APIKEY 请求头存在且值正确 |
9010 | SCAN_TEXT_ERROR | 文本提示未通过内容审核 | 修改提示词,移除任何敏感或违规内容 |
9038 | PROHIBITED_CONTENT | 生成输出图片包含禁止内容 | 调整提示词/风格/输入后重试 |
9051 | COINS_NOT_ENOUGH | 积分/余额不足 | 充值账户积分后重试 |
📄 如需完整通用 API 错误码列表,请参阅 错误码参考。