เอกสาร API เครื่องมือแก้ไขภาพอัจฉริยะ#
URLพื้นฐาน:
https://api.ideal.house
เวอร์ชัน: v1
อัปเดต: 2026-03-06
📖 ภาพรวม#
เครื่องมือแก้ไขภาพอัจฉริยะ API ช่วยให้คุณแก้ไขและแปลงภาพอย่างชาญฉลาดโดยใช้ AI. โดยให้ภาพต้นฉบับและคำสั่งข้อความแบบไม่บังคับ AI จะทำการแก้ไขอัจฉริยะกับภาพตามโหมดโมเดลที่เลือก กระบวนการทำงานเป็นแบบ asynchron และประกอบด้วยสองขั้นตอน:
- สร้างงาน — ส่งภาพและพารามิเตอร์ของคุณ จากนั้นรับ
taskId - ตรวจสอบผลลัพธ์ — ใช้
taskIdเพื่อตรวจสอบสถานะงานและรับภาพที่แก้ไขแล้ว
🔐 การรับรองความถูกต้อง#
คำขอ API ทั้งหมดต้องได้รับการยืนยันตัวตนโดยใช้ คีย์ API
รวมคีย์ API ของคุณในหัวข้อความขอ:
| หัวข้อ | ค่า |
|---|---|
APIKEY | your_api_key_here |
⚠️ รักษาความปลอดภัยคีย์ API ของคุณ อย่าเปิดเผยในโค้ดฝั่งไคลเอนต์หรือรีโพสิทอรีสาธารณะ
💰 การหักเครดิต#
[!WARNING] 🪙 เครดิตจะถูกหักตาม
modelTypeที่เลือกเมื่อสร้างงานสำเร็จ หากงาน ล้มเหลว ในที่สุด เครดิตที่ถูกหักจะ ถูกคืน เข้าบัญชีของคุณโดยอัตโนมัติ
เครดิตไม่เพียงพอจะคืนรหัสข้อผิดพลาด9051📄 ดู อ้างอิงการหักเครดิต
โมเดล (modelType) | เครดิตที่หัก |
|---|---|
Flash | 1 เครดิต |
Base | 3 เครดิต |
Pro | 10 เครดิต |
📌 เอนด์พอยต์ API#
1. สร้างงาน เครื่องมือแก้ไขภาพอัจฉริยะ#
สร้างงาน AI เครื่องมือแก้ไขภาพอัจฉริยะ ใหม่และคืน taskId ที่ไม่ซ้ำกันสำหรับการตรวจสอบสถานะเป็นระยะ.
เอนด์พอยต์
POST /api/v1/magicEditor/generate
หัวข้อความขอ
| หัวข้อ | จำเป็น | คำอธิบาย |
|---|---|---|
APIKEY | ✅ ใช่ | คีย์การยืนยันตัวตน API ของคุณ |
Content-Type | ✅ ใช่ | application/json |
เนื้อหาคำขอ
| ฟิลด์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
imageUrl | string | ✅ ใช่ | URL ของภาพต้นฉบับที่จะแก้ไข |
prompt | string | ⚠️ เงื่อนไข | คำสั่งข้อความที่อธิบายการแก้ไขที่ต้องการ บังคับเมื่อ modelType เป็น Base; ไม่บังคับสำหรับโหมด Flash และ Pro |
modelType | string | ❌ ไม่บังคับ | ประเภทโมเดล Enum: Flash, Base, Pro ค่าเริ่มต้นคือ Flash |
🖼️ ข้อกำหนดของภาพ: ใช้ JPG/JPEG, PNG หรือ WebP แต่ละภาพต้องไม่เกิน 20 MB โดยมีขนาดตั้งแต่ 128 × 128 px ถึง 6,000 × 6,000 px (รวมขอบเขต) ภาพที่เกินขนาดพิกเซลสูงสุดจะถูกย่อสัดส่วนอัตโนมัติให้พอดีกับ 6,000 × 6,000 px ก่อนการประมวลผล URL ของภาพต้องเข้าถึงได้โดยตรงโดยเซิร์ฟเวอร์ API
ประเภทโมเดล
| ค่า | คำอธิบาย | บังคับใช้คำสั่ง |
|---|---|---|
Flash | ค่าเริ่มต้น การแก้ไขอย่างรวดเร็วด้วยการสร้างอัจฉริยะโดย AI อัตโนมัติ | ❌ ไม่บังคับ |
Base | การแก้ไขตามคำสั่งข้อความ — ใช้คำสั่งของคุณเพื่อกำหนดผลลัพธ์อย่างแม่นยำ | ✅ บังคับ |
Pro | การแก้ไขคุณภาพสูงกว่าพร้อมผลลัพธ์ที่ละเอียดมากขึ้น | ❌ ไม่บังคับ |
⚠️ สำคัญ: เมื่อ
modelTypeเป็นBaseฟิลด์promptต้อง ให้ไว้ คำขอที่มีmodelType=Baseและไม่มีpromptจะคืนค่าเป็นข้อผิดพลาดพารามิเตอร์
📥 ตัวอย่างคำขอ#
cURL
# Flash mode (default) — prompt is optional
curl -X POST "https://api.ideal.house/api/v1/magicEditor/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"modelType": "Flash"
}'
# Base mode — prompt is required
curl -X POST "https://api.ideal.house/api/v1/magicEditor/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"prompt": "Change the wall color to warm beige and add wooden flooring",
"modelType": "Base"
}'
# Pro mode — prompt is optional
curl -X POST "https://api.ideal.house/api/v1/magicEditor/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"prompt": "Modern Scandinavian style interior",
"modelType": "Pro"
}'
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class MagicEditorApiExample {
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();
// Flash mode (default) — no prompt needed
String requestBody = """
{
"imageUrl": "https://example.com/room.jpg",
"modelType": "Flash"
}
""";
// Base mode — prompt is required
// String requestBody = """
// {
// "imageUrl": "https://example.com/room.jpg",
// "prompt": "Change the wall color to warm beige and add wooden flooring",
// "modelType": "Base"
// }
// """;
// Pro mode — prompt is optional
// String requestBody = """
// {
// "imageUrl": "https://example.com/room.jpg",
// "prompt": "Modern Scandinavian style interior",
// "modelType": "Pro"
// }
// """;
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/magicEditor/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"
}
# Flash mode (default) — no prompt needed
payload = {
"imageUrl": "https://example.com/room.jpg",
"modelType": "Flash"
}
# Base mode — prompt is required
# payload = {
# "imageUrl": "https://example.com/room.jpg",
# "prompt": "Change the wall color to warm beige and add wooden flooring",
# "modelType": "Base"
# }
# Pro mode — prompt is optional
# payload = {
# "imageUrl": "https://example.com/room.jpg",
# "prompt": "Modern Scandinavian style interior",
# "modelType": "Pro"
# }
response = requests.post(
f"{BASE_URL}/api/v1/magicEditor/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 createMagicEditorTask() {
try {
const response = await axios.post(
`${BASE_URL}/api/v1/magicEditor/generate`,
{
// Flash mode (default) — no prompt needed
imageUrl: 'https://example.com/room.jpg',
modelType: 'Flash'
// Base mode — prompt is required:
// imageUrl: 'https://example.com/room.jpg',
// prompt: 'Change the wall color to warm beige and add wooden flooring',
// modelType: 'Base'
// Pro mode — prompt is optional:
// imageUrl: 'https://example.com/room.jpg',
// prompt: 'Modern Scandinavian style interior',
// 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);
}
}
createMagicEditorTask();
📤 การตอบสนอง#
คำตอบสำเร็จ
{
"code": 0,
"message": "success",
"data": 1234567890123456789
}
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
code | integer | 0 บ่งชี้ว่าสำเร็จ |
message | string | ข้อความตอบกลับ |
data | long | ID งานเฉพาะสำหรับการตรวจสอบสถานะผลลัพธ์ |
2. รับผลลัพธ์งาน#
ดึงสถานะปัจจุบันและผลลัพธ์ของงาน เครื่องมือแก้ไขภาพอัจฉริยะ ที่สร้างไว้ก่อนหน้า.
เอนด์พอยต์
GET /api/v1/magicEditor/result
หัวข้อความขอ
| หัวข้อ | จำเป็น | คำอธิบาย |
|---|---|---|
APIKEY | ✅ ใช่ | คีย์การยืนยันตัวตน API ของคุณ |
พารามิเตอร์ควอรี
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
taskId | long | ✅ ใช่ | ID งานที่ส่งกลับจากเอนด์พอยต์สร้างงาน |
📥 ตัวอย่างคำขอ#
cURL
curl -X GET "https://api.ideal.house/api/v1/magicEditor/result?taskId=1234567890123456789" \
-H "APIKEY: your_api_key_here"
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class MagicEditorResultExample {
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/magicEditor/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/magicEditor/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", "Termination"):
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/magicEditor/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', 'Termination'].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",
"prompt": "Change the wall color to warm beige and add wooden flooring",
"modelType": "Base"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/magic_editor_result.jpg",
"width": 1024,
"height": 1024
}
}
}
การตอบสนอง (งานกำลังประมวลผล / อยู่ในคิว)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Processing",
"waitNumber": 1,
"percentage": 40,
"input": {
"imageUrl": "https://example.com/room.jpg",
"modelType": "Flash"
},
"output": null
}
}
การตอบสนอง (งานล้มเหลว)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Failed",
"waitNumber": 0,
"percentage": 0,
"input": {
"imageUrl": "https://example.com/room.jpg",
"modelType": "Flash"
},
"output": null
}
}
ฟิลด์คำตอบ
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
id | long | ตัวระบุเฉพาะของงาน |
status | string | สถานะงานปัจจุบัน (ดู สถานะงาน) |
waitNumber | integer | จำนวนงานที่อยู่ข้างหน้าในคิว (0 หมายถึงกำลังดำเนินการอยู่) |
percentage | integer | ร้อยละความคืบหน้าของงาน (0–100) |
input | object | พารามิเตอร์อินพุตต้นฉบับของงาน |
input.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 | งานล้มเหลวเนื่องจากข้อผิดพลาด |
Termination | งานถูกขัดจังหวะหรือยุติ |
ตรวจสอบสถานะทุก 3-5 วินาที ดู ขีดจำกัดงาน API
❌ การตอบสนองข้อผิดพลาด#
คำตอบข้อผิดพลาดทั้งหมดใช้โครงสร้าง JSON เดียวกัน:
{
"code": 5002,
"message": "Invalid API Key",
"data": null
}
อ้างอิงรหัสข้อผิดพลาด#
| รหัส | ชื่อ | คำอธิบาย | การดำเนินการที่แนะนำ |
|---|---|---|---|
1001 | FAILED | คำขอล้มเหลว (ข้อผิดพลาดทั่วไป) | ตรวจสอบฟิลด์ message เพื่อรับรายละเอียดข้อผิดพลาดเฉพาะ |
1003 | INTERNAL_ERROR | ข้อผิดพลาดเซิร์ฟเวอร์ภายใน | ลองใหม่หลังจากพักสั้นๆ; ติดต่อฝ่ายสนับสนุนหากยังคงเกิดขึ้น |
1011 | PARAM_ERROR | ข้อผิดพลาดพารามิเตอร์คำขอ — e.g, prompt ขาดหายเมื่อ modelType=Base | ตรวจสอบว่าให้ prompt ไว้เมื่อใช้โหมด Base |
5002 | API_KEY_INVALID | คีย์ API ไม่ถูกต้องหรือไม่พบ | ตรวจสอบว่าเฮดเดอร์ APIKEY มีอยู่และค่าถูกต้อง |
9010 | SCAN_TEXT_ERROR | พรอมต์ข้อความไม่ผ่านการตรวจสอบเนื้อหา | แก้ไขพรอมต์เพื่อลบเนื้อหาอ่อนไหวหรือต้องห้าม |
9038 | PROHIBITED_CONTENT | ภาพผลลัพธ์ที่สร้างมามีเนื้อหาต้องห้าม | ปรับพรอมต์/สไตล์/อินพุตแล้วลองใหม่ |
9051 | COINS_NOT_ENOUGH | เหรียญ/เครดิตไม่เพียงพอ | เติมเครดิตในบัญชีของคุณแล้วลองใหม่ |
📄 สำหรับรายการรหัสข้อผิดพลาด API ทั่วไปทั้งหมด ดู อ้างอิงรหัสข้อผิดพลาด