家居装饰 API 文档#
基础 URL:
https://api.ideal.house
版本: v1
更新: 2026-05-21
📖 概述#
家居装饰 API 为室内图片生成装饰创意。支持可选文本引导、参考图片、风格选择和模型模式。
工作流为异步方式:
- 创建任务 — 提交
imageUrl和可选参数,然后获取taskId。 - 轮询结果 — 使用
taskId获取任务状态和生成图片。
🔐 认证#
| 头字段 | 值 |
|---|---|
APIKEY | your_api_key_here |
💰 积分扣减#
[!WARNING] 任务成功创建时扣除积分。如果任务最终失败,已扣除积分将自动退还。
积分不足将返回错误码9051。参见积分扣减参考。
模型(modelType) | 扣除积分 |
|---|---|
Base | 3 积分 |
Pro | 10 积分 |
若未提供 modelType,则默认使用 Base。
🎨 风格选项#
此 API 支持可选的风格参数,由 API 风格配置 端点返回。
使用方式:
GET /api/v1/style/home_decor_ideas/getStyles
| 风格组 | 请求字段 | 描述 |
|---|---|---|
spaceType | spaceStyleId | 空间或房间类型选项 |
decorStyle | homeDecorStyleId | 装饰风格选项 |
每个选项包含 name、id 和 url。将选项 id 传入对应请求字段。
📌 API 端点#
1. 创建家居装饰任务#
端点
POST /api/v1/homeDecor/generate
请求头
| 头字段 | 必需 | 描述 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
Content-Type | ✅ 是 | application/json |
请求体
| 字段 | 类型 | 必需 | 描述 |
|---|---|---|---|
imageUrl | string | ✅ 是 | 源室内图片的 URL |
referenceUrl | string | ❌ 可选 | 参考图片 URL 用于引导装饰风格 |
spaceStyleId | string | ❌ 可选 | 来自 spaceType 风格选项的空间类型 ID |
homeDecorStyleId | string | ❌ 可选 | 来自 decorStyle 风格选项的装饰风格 ID |
prompt | string | ❌ 可选 | 期望结果的文本引导 |
modelType | string | ❌ 可选 | 枚举值:Base、Pro。默认为 Base |
仅
imageUrl为必填项,其余字段均为可选。
🖼️ 图片要求: 所有源图片和参考图片必须使用 JPG/JPEG、PNG 或 WebP。每张图片不得超过 20 MB,尺寸从 128 × 128 像素到 6,000 × 6,000 像素(含)。超出最大像素尺寸的图片会自动按比例缩放以适配 6,000 × 6,000 像素后再处理。图片 URLs 必须由 API 服务器直接访问。
📥 请求示例#
cURL
curl -X POST "https://api.ideal.house/api/v1/homeDecor/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"referenceUrl": "https://example.com/reference.jpg",
"spaceStyleId": "Indoor_Living Room",
"homeDecorStyleId": "Holidays_Cozy Christmas",
"prompt": "warm seasonal decor with natural textures",
"modelType": "Base"
}'
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class HomeDecorApiExample {
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/room.jpg",
"referenceUrl": "https://example.com/reference.jpg",
"spaceStyleId": "Indoor_Living Room",
"homeDecorStyleId": "Holidays_Cozy Christmas",
"prompt": "warm seasonal decor with natural textures",
"modelType": "Base"
}
""";
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/homeDecor/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/room.jpg",
"referenceUrl": "https://example.com/reference.jpg",
"spaceStyleId": "Indoor_Living Room",
"homeDecorStyleId": "Holidays_Cozy Christmas",
"prompt": "warm seasonal decor with natural textures",
"modelType": "Base"
}
response = requests.post(
f"{BASE_URL}/api/v1/homeDecor/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 createHomeDecorTask() {
try {
const response = await axios.post(
`${BASE_URL}/api/v1/homeDecor/generate`,
{
imageUrl: 'https://example.com/room.jpg',
referenceUrl: 'https://example.com/reference.jpg',
spaceStyleId: 'Indoor_Living Room',
homeDecorStyleId: 'Holidays_Cozy Christmas',
prompt: 'warm seasonal decor with natural textures',
modelType: 'Base'
},
{
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);
}
}
createHomeDecorTask();
📤 响应#
{
"code": 0,
"message": "success",
"data": 1234567890123456789
}
2. 获取任务结果#
端点
GET /api/v1/homeDecor/result
请求头
| 头字段 | 必需 | 描述 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
查询参数
| 参数 | 类型 | 必需 | 描述 |
|---|---|---|---|
taskId | long | ✅ 是 | 创建端点返回的任务 ID |
📥 请求示例#
cURL
curl -X GET "https://api.ideal.house/api/v1/homeDecor/result?taskId=1234567890123456789" \
-H "APIKEY: your_api_key_here"
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class HomeDecorResultExample {
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/homeDecor/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/homeDecor/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 pollHomeDecorResult(taskId) {
const headers = { APIKEY: API_KEY };
while (true) {
const response = await axios.get(
`${BASE_URL}/api/v1/homeDecor/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));
}
}
pollHomeDecorResult(1234567890123456789n);
📤 响应示例#
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Success",
"waitNumber": 0,
"percentage": 100,
"input": {
"imageUrl": "https://example.com/room.jpg",
"refImageUrl": "https://example.com/reference.jpg",
"spaceStyleId": "Indoor_Living Room",
"homeDecorStyleId": "Holidays_Cozy Christmas",
"prompt": "warm seasonal decor with natural textures",
"modelType": "Base"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/home_decor_result.jpg",
"width": 1024,
"height": 1024
}
}
}
响应(任务处理中/排队中)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Processing",
"waitNumber": 1,
"percentage": 45,
"input": {
"imageUrl": "https://example.com/room.jpg",
"modelType": "Base"
},
"output": null
}
}
响应(任务失败)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Failed",
"waitNumber": 0,
"percentage": 0,
"input": {
"imageUrl": "https://example.com/room.jpg",
"modelType": "Base"
},
"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 | 积分不足 |
完整通用错误定义,参见错误码参考。