Ideal House
ข้ามไปยังเนื้อหา

เอกสาร API เครื่องมือแก้ไขภาพอัจฉริยะ#

URLพื้นฐาน: https://api.ideal.house
เวอร์ชัน: v1
อัปเดต: 2026-03-06


📖 ภาพรวม#

เครื่องมือแก้ไขภาพอัจฉริยะ API ช่วยให้คุณแก้ไขและแปลงภาพอย่างชาญฉลาดโดยใช้ AI. โดยให้ภาพต้นฉบับและคำสั่งข้อความแบบไม่บังคับ AI จะทำการแก้ไขอัจฉริยะกับภาพตามโหมดโมเดลที่เลือก กระบวนการทำงานเป็นแบบ asynchron และประกอบด้วยสองขั้นตอน:

  1. สร้างงาน — ส่งภาพและพารามิเตอร์ของคุณ จากนั้นรับ taskId
  2. ตรวจสอบผลลัพธ์ — ใช้ taskId เพื่อตรวจสอบสถานะงานและรับภาพที่แก้ไขแล้ว

🔐 การรับรองความถูกต้อง#

คำขอ API ทั้งหมดต้องได้รับการยืนยันตัวตนโดยใช้ คีย์ API

รวมคีย์ API ของคุณในหัวข้อความขอ:

หัวข้อค่า
APIKEYyour_api_key_here

⚠️ รักษาความปลอดภัยคีย์ API ของคุณ อย่าเปิดเผยในโค้ดฝั่งไคลเอนต์หรือรีโพสิทอรีสาธารณะ


💰 การหักเครดิต#

[!WARNING] 🪙 เครดิตจะถูกหักตาม modelType ที่เลือกเมื่อสร้างงานสำเร็จ หากงาน ล้มเหลว ในที่สุด เครดิตที่ถูกหักจะ ถูกคืน เข้าบัญชีของคุณโดยอัตโนมัติ
เครดิตไม่เพียงพอจะคืนรหัสข้อผิดพลาด 9051 📄 ดู อ้างอิงการหักเครดิต

โมเดล (modelType)เครดิตที่หัก
Flash1 เครดิต
Base3 เครดิต
Pro10 เครดิต

📌 เอนด์พอยต์ API#


1. สร้างงาน เครื่องมือแก้ไขภาพอัจฉริยะ#

สร้างงาน AI เครื่องมือแก้ไขภาพอัจฉริยะ ใหม่และคืน taskId ที่ไม่ซ้ำกันสำหรับการตรวจสอบสถานะเป็นระยะ.

เอนด์พอยต์

ข้อความธรรมดา
POST /api/v1/magicEditor/generate

หัวข้อความขอ

หัวข้อจำเป็นคำอธิบาย
APIKEY✅ ใช่คีย์การยืนยันตัวตน API ของคุณ
Content-Type✅ ใช่application/json

เนื้อหาคำขอ

ฟิลด์ประเภทจำเป็นคำอธิบาย
imageUrlstring✅ ใช่URL ของภาพต้นฉบับที่จะแก้ไข
promptstring⚠️ เงื่อนไขคำสั่งข้อความที่อธิบายการแก้ไขที่ต้องการ บังคับเมื่อ modelType เป็น Base; ไม่บังคับสำหรับโหมด Flash และ Pro
modelTypestring❌ ไม่บังคับประเภทโมเดล 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
bash
# 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)
java
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)
python
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)
javascript
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();

📤 การตอบสนอง#

คำตอบสำเร็จ

json
{
  "code": 0,
  "message": "success",
  "data": 1234567890123456789
}
ฟิลด์ประเภทคำอธิบาย
codeinteger0 บ่งชี้ว่าสำเร็จ
messagestringข้อความตอบกลับ
datalongID งานเฉพาะสำหรับการตรวจสอบสถานะผลลัพธ์

2. รับผลลัพธ์งาน#

ดึงสถานะปัจจุบันและผลลัพธ์ของงาน เครื่องมือแก้ไขภาพอัจฉริยะ ที่สร้างไว้ก่อนหน้า.

เอนด์พอยต์

ข้อความธรรมดา
GET /api/v1/magicEditor/result

หัวข้อความขอ

หัวข้อจำเป็นคำอธิบาย
APIKEY✅ ใช่คีย์การยืนยันตัวตน API ของคุณ

พารามิเตอร์ควอรี

พารามิเตอร์ประเภทจำเป็นคำอธิบาย
taskIdlong✅ ใช่ID งานที่ส่งกลับจากเอนด์พอยต์สร้างงาน

📥 ตัวอย่างคำขอ#

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

📤 การตอบสนอง#

คำตอบสำเร็จ (งานเสร็จสมบูรณ์)

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

การตอบสนอง (งานกำลังประมวลผล / อยู่ในคิว)

json
{
  "code": 0,
  "message": "success",
  "data": {
    "id": 1234567890123456789,
    "status": "Processing",
    "waitNumber": 1,
    "percentage": 40,
    "input": {
      "imageUrl": "https://example.com/room.jpg",
      "modelType": "Flash"
    },
    "output": null
  }
}

การตอบสนอง (งานล้มเหลว)

json
{
  "code": 0,
  "message": "success",
  "data": {
    "id": 1234567890123456789,
    "status": "Failed",
    "waitNumber": 0,
    "percentage": 0,
    "input": {
      "imageUrl": "https://example.com/room.jpg",
      "modelType": "Flash"
    },
    "output": null
  }
}

ฟิลด์คำตอบ

ฟิลด์ประเภทคำอธิบาย
idlongตัวระบุเฉพาะของงาน
statusstringสถานะงานปัจจุบัน (ดู สถานะงาน)
waitNumberintegerจำนวนงานที่อยู่ข้างหน้าในคิว (0 หมายถึงกำลังดำเนินการอยู่)
percentageintegerร้อยละความคืบหน้าของงาน (0–100)
inputobjectพารามิเตอร์อินพุตต้นฉบับของงาน
input.imageUrlstringภาพต้นฉบับ URL
input.promptstringคำสั่งข้อความ (หากให้ไว้)
input.modelTypestringประเภทโมเดลที่ใช้
outputobjectผลลัพธ์การสร้าง (ใช้ได้เฉพาะเมื่อ status เป็น Success)
output.resultUrlstringURL ไปยังภาพผลลัพธ์ที่แก้ไขแล้ว
output.widthintegerความกว้างของผลลัพธ์ในพิกเซล
output.heightintegerความสูงของผลลัพธ์ในพิกเซล

📊 สถานะงาน#

สถานะคำอธิบาย
Unprocessedงานถูกสร้างแล้วแต่ยังไม่เริ่ม
Processingงานกำลังถูกประมวลผล
Successงานเสร็จสมบูรณ์ — ผลลัพธ์พร้อมใช้งาน
Failedงานล้มเหลวเนื่องจากข้อผิดพลาด
Terminationงานถูกขัดจังหวะหรือยุติ

ตรวจสอบสถานะทุก 3-5 วินาที ดู ขีดจำกัดงาน API


❌ การตอบสนองข้อผิดพลาด#

คำตอบข้อผิดพลาดทั้งหมดใช้โครงสร้าง JSON เดียวกัน:

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

อ้างอิงรหัสข้อผิดพลาด#

รหัสชื่อคำอธิบายการดำเนินการที่แนะนำ
1001FAILEDคำขอล้มเหลว (ข้อผิดพลาดทั่วไป)ตรวจสอบฟิลด์ message เพื่อรับรายละเอียดข้อผิดพลาดเฉพาะ
1003INTERNAL_ERRORข้อผิดพลาดเซิร์ฟเวอร์ภายในลองใหม่หลังจากพักสั้นๆ; ติดต่อฝ่ายสนับสนุนหากยังคงเกิดขึ้น
1011PARAM_ERRORข้อผิดพลาดพารามิเตอร์คำขอ — e.g, prompt ขาดหายเมื่อ modelType=Baseตรวจสอบว่าให้ prompt ไว้เมื่อใช้โหมด Base
5002API_KEY_INVALIDคีย์ API ไม่ถูกต้องหรือไม่พบตรวจสอบว่าเฮดเดอร์ APIKEY มีอยู่และค่าถูกต้อง
9010SCAN_TEXT_ERRORพรอมต์ข้อความไม่ผ่านการตรวจสอบเนื้อหาแก้ไขพรอมต์เพื่อลบเนื้อหาอ่อนไหวหรือต้องห้าม
9038PROHIBITED_CONTENTภาพผลลัพธ์ที่สร้างมามีเนื้อหาต้องห้ามปรับพรอมต์/สไตล์/อินพุตแล้วลองใหม่
9051COINS_NOT_ENOUGHเหรียญ/เครดิตไม่เพียงพอเติมเครดิตในบัญชีของคุณแล้วลองใหม่

📄 สำหรับรายการรหัสข้อผิดพลาด API ทั่วไปทั้งหมด ดู อ้างอิงรหัสข้อผิดพลาด