เอกสาร API สร้างวิดีโอจากภาพ#
URLพื้นฐาน:
https://api.ideal.house
เวอร์ชัน: v1
อัปเดต: 2026-03-25
📖 ภาพรวม#
API สร้างวิดีโอจากภาพ ช่วยให้คุณสร้างวิดีโอด้วย AI จากภาพต้นฉบับเดียว หรือระบุทั้งภาพ เฟรมแรก และภาพ เฟรมสุดท้าย เพื่อควบคุมจุดเริ่มต้นและจุดสิ้นสุดของวิดีโอที่สร้างได้ กระบวนการทำงานเป็นแบบไม่ซิงโครนัสและประกอบด้วยสองขั้นตอน:
- สร้างงาน — ส่งภาพของคุณ, ประเภทโมเดล, ระยะเวลา และความละเอียด จากนั้นรับ
taskId - ตรวจสอบผลลัพธ์ — ใช้
taskIdเพื่อสอบถามสถานะงานและรับวิดีโอที่สร้างแล้ว
🔐 การรับรองความถูกต้อง#
คำขอ API ทั้งหมดต้องได้รับการยืนยันตัวตนโดยใช้ คีย์ API
รวมคีย์ API ของคุณในหัวข้อความขอ:
| หัวข้อ | ค่า |
|---|---|
APIKEY | your_api_key_here |
⚠️ รักษาความปลอดภัยคีย์ API ของคุณ อย่าเปิดเผยในโค้ดฝั่งไคลเอนต์หรือรีโพสิทอรีสาธารณะ
💰 การหักเครดิต#
[!WARNING] 🪙 เครดิตจะถูกหักตาม
modelType,resolution,durationที่เลือก และว่าgenerateAudioถูกเปิดใช้งานหรือไม่ เมื่อสร้างงานสำเร็จ หากงาน ล้มเหลว ในที่สุด เครดิตที่ถูกหักจะ ถูกคืนโดยอัตโนมัติ กลับเข้าบัญชีของคุณ
เครดิตไม่เพียงพอจะคืนรหัสข้อผิดพลาด9051📄 ดู อ้างอิงการหักเครดิต
โมเดล Flash (modelType: "Flash", ค่าเริ่มต้น):
| ความละเอียด | ระยะเวลา | เครดิตที่ถูกหัก |
|---|---|---|
480p | 5s | 10 เครดิต |
480p | 10s | 20 เครดิต |
720p | 5s | 20 เครดิต |
720p | 10s | 40 เครดิต |
1080p | 5s | 40 เครดิต |
1080p | 10s | 80 เครดิต |
โมเดล Base (modelType: "Base", generateAudio: false):
| ความละเอียด | ระยะเวลา | เครดิตที่ถูกหัก |
|---|---|---|
480p | 5s | 8 เครดิต |
480p | 10s | 16 เครดิต |
720p | 5s | 16 เครดิต |
720p | 10s | 32 เครดิต |
1080p | 5s | 32 เครดิต |
1080p | 10s | 64 เครดิต |
โมเดล Base พร้อมเสียง (modelType: "Base", generateAudio: true):
| ความละเอียด | ระยะเวลา | เครดิตที่ถูกหัก |
|---|---|---|
480p | 5s | 16 เครดิต |
480p | 10s | 32 เครดิต |
720p | 5s | 32 เครดิต |
720p | 10s | 64 เครดิต |
1080p | 5s | 64 เครดิต |
1080p | 10s | 128 เครดิต |
📌 เอนด์พอยต์ API#
1. สร้างงานสร้างวิดีโอจากภาพ#
สร้างงานสร้างวิดีโอจากภาพด้วย AI ใหม่ และคืน taskId ที่ไม่ซ้ำกันสำหรับการตรวจสอบสถานะ
เอนด์พอยต์
POST /api/v1/imageToVideo/generate
หัวข้อความขอ
| หัวข้อ | จำเป็น | คำอธิบาย |
|---|---|---|
APIKEY | ✅ ใช่ | คีย์ API สำหรับยืนยันตัวตนของคุณ |
Content-Type | ✅ ใช่ | application/json |
เนื้อหาคำขอ
| ฟิลด์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
imageUrl | string | ✅ ใช่ | URL ของภาพต้นฉบับ ในโหมดเฟรมแรก-เฟรมสุดท้าย ฟิลด์นี้ทำหน้าที่เป็น เฟรมแรก |
duration | integer | ✅ ใช่ | ระยะเวลาวิดีโอในหน่วยวินาที Enum: 5, 10 |
resolution | string | ✅ ใช่ | ความละเอียดเอาต์พุตวิดีโอ Enum: 480p, 720p, 1080p |
modelType | string | ❌ ตัวเลือก | ประเภทโมเดลที่จะใช้สำหรับการสร้าง Enum: Flash, Base ค่าเริ่มต้นเป็น Flash |
generateAudio | boolean | ❌ ตัวเลือก | ว่าจะสร้างเสียงพื้นหลังสำหรับวิดีโอหรือไม่ ใช้ได้เฉพาะเมื่อ modelType เป็น Base ค่าเริ่มต้นเป็น false |
prompt | string | ❌ ตัวเลือก | ข้อความพรอมป์ตเพื่อแนะนำสไตล์และท่าทางของการสร้างวิดีโอ |
lastImageUrl | string | ❌ ตัวเลือก | URL ของภาพ เฟรมสุดท้าย เมื่อระบุ จะเปิดใช้งาน โหมดเฟรมแรก-เฟรมสุดท้าย: วิดีโอจะเปลี่ยนจาก imageUrl (เฟรมแรก) ไปยัง lastImageUrl (เฟรมสุดท้าย) |
💡 โหมดเฟรมแรก-เฟรมสุดท้าย: หาก
lastImageUrlถูกระบุ API จะสร้างวิดีโอที่เปลี่ยนผ่านอย่างนุ่มนวลจากภาพเฟรมแรก (imageUrl) ไปยังภาพเฟรมสุดท้าย (lastImageUrl) ซึ่งช่วยให้คุณควบคุมจุดเริ่มต้นและจุดสิ้นสุดของวิดีโอได้อย่างแม่นยำ
🖼️ ข้อกำหนดของภาพ: ภาพเฟรมแรกและภาพเฟรมสุดท้าย (ตัวเลือก) ต้องใช้ JPG/JPEG, PNG หรือ WebP แต่ละภาพต้องมีขนาดไม่เกิน 20 MB โดยมีมิติตั้งแต่ 128 × 128 px ถึง 6,000 × 6,000 px (รวมขอบเขต) ภาพที่มีมิติพิกเซลเกินค่าสูงสุดจะถูกย่อขนาดลงตามสัดส่วนให้อยู่ภายใน 6,000 × 6,000 px ก่อนการประมวลผล URLs ของภาพต้องเข้าถึงได้โดยตรงโดยเซิร์ฟเวอร์ API
ประเภทโมเดล
| ค่า | คำอธิบาย |
|---|---|
Flash | ค่าเริ่มต้น ความเร็วในการสร้างที่เร็วกว่าพร้อมคุณภาพเอาต์พุตที่สูง |
Base | โมเดลทางเลือก — รองรับการสร้างเสียง AI แบบตัวเลือก (generateAudio) |
ตัวเลือกระยะเวลา
| ค่า | คำอธิบาย |
|---|---|
5 | วิดีโอยาว 5 วินาที |
10 | วิดีโอยาว 10 วินาที |
ตัวเลือกความละเอียด
| ค่า | คำอธิบาย |
|---|---|
480p | ความละเอียดมาตรฐาน — ประมวลผลเร็ว |
720p | ความละเอียดสูง — คุณภาพเอาต์พุตสูงกว่า |
1080p | Full HD — คุณภาพผลลัพธ์สูงสุด |
📥 ตัวอย่างคำขอ#
cURL
# Flash model (default) — single source image
curl -X POST "https://api.ideal.house/api/v1/imageToVideo/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "720p",
"modelType": "Flash",
"prompt": "Gentle camera zoom in with soft lighting"
}'
# Base model with audio — single source image
curl -X POST "https://api.ideal.house/api/v1/imageToVideo/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "1080p",
"modelType": "Base",
"generateAudio": true,
"prompt": "Peaceful living room ambiance"
}'
# First-last frame mode — specify both first and last frame
curl -X POST "https://api.ideal.house/api/v1/imageToVideo/generate" \
-H "APIKEY: your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"imageUrl": "https://example.com/room-day.jpg",
"lastImageUrl": "https://example.com/room-night.jpg",
"duration": 10,
"resolution": "720p",
"modelType": "Flash",
"prompt": "Smooth day to night transition"
}'
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class ImageToVideoApiExample {
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 model — standard mode
String requestBody = """
{
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "720p",
"modelType": "Flash",
"prompt": "Gentle camera zoom in with soft lighting"
}
""";
// Base model with audio
// String requestBody = """
// {
// "imageUrl": "https://example.com/room.jpg",
// "duration": 5,
// "resolution": "1080p",
// "modelType": "Base",
// "generateAudio": true,
// "prompt": "Peaceful living room ambiance"
// }
// """;
// First-last frame mode
// String requestBody = """
// {
// "imageUrl": "https://example.com/room-day.jpg",
// "lastImageUrl": "https://example.com/room-night.jpg",
// "duration": 10,
// "resolution": "720p",
// "modelType": "Flash",
// "prompt": "Smooth day to night transition"
// }
// """;
Request request = new Request.Builder()
.url(BASE_URL + "/api/v1/imageToVideo/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 model — single source image
payload = {
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "720p",
"modelType": "Flash",
"prompt": "Gentle camera zoom in with soft lighting"
}
# Base model with audio
# payload = {
# "imageUrl": "https://example.com/room.jpg",
# "duration": 5,
# "resolution": "1080p",
# "modelType": "Base",
# "generateAudio": True,
# "prompt": "Peaceful living room ambiance"
# }
# First-last frame mode
# payload = {
# "imageUrl": "https://example.com/room-day.jpg",
# "lastImageUrl": "https://example.com/room-night.jpg",
# "duration": 10,
# "resolution": "720p",
# "modelType": "Flash",
# "prompt": "Smooth day to night transition"
# }
response = requests.post(
f"{BASE_URL}/api/v1/imageToVideo/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 createVideoTask() {
try {
// Flash model — standard mode
const payload = {
imageUrl: 'https://example.com/room.jpg',
duration: 5,
resolution: '720p',
modelType: 'Flash',
prompt: 'Gentle camera zoom in with soft lighting'
};
// Base model with audio:
// const payload = {
// imageUrl: 'https://example.com/room.jpg',
// duration: 5,
// resolution: '1080p',
// modelType: 'Base',
// generateAudio: true,
// prompt: 'Peaceful living room ambiance'
// };
// First-last frame mode:
// const payload = {
// imageUrl: 'https://example.com/room-day.jpg',
// lastImageUrl: 'https://example.com/room-night.jpg',
// duration: 10,
// resolution: '720p',
// modelType: 'Flash',
// prompt: 'Smooth day to night transition'
// };
const response = await axios.post(
`${BASE_URL}/api/v1/imageToVideo/generate`,
payload,
{
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);
}
}
createVideoTask();
📤 การตอบสนอง#
คำตอบสำเร็จ
{
"code": 0,
"message": "success",
"data": 1234567890123456789
}
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
code | integer | 0 บ่งชี้ว่าสำเร็จ |
message | string | ข้อความตอบกลับ |
data | long | รหัสงานที่ไม่ซ้ำกันสำหรับการตรวจสอบสถานะ |
2. รับผลลัพธ์งาน#
ดึงสถานะปัจจุบันและผลลัพธ์ของงานสร้างวิดีโอจากภาพที่เคยสร้างไว้ก่อนหน้า
เอนด์พอยต์
GET /api/v1/imageToVideo/result
หัวข้อความขอ
| หัวข้อ | จำเป็น | คำอธิบาย |
|---|---|---|
APIKEY | ✅ ใช่ | คีย์ API สำหรับยืนยันตัวตนของคุณ |
พารามิเตอร์คิวรี
| พารามิเตอร์ | ประเภท | จำเป็น | คำอธิบาย |
|---|---|---|---|
taskId | long | ✅ ใช่ | รหัสงานที่คืนจากเอนด์พอยต์สร้างงาน |
📥 ตัวอย่างคำขอ#
cURL
curl -X GET "https://api.ideal.house/api/v1/imageToVideo/result?taskId=1234567890123456789" \
-H "APIKEY: your_api_key_here"
Java (OkHttp)
import okhttp3.*;
import java.io.IOException;
public class ImageToVideoResultExample {
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/imageToVideo/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/imageToVideo/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(5) # Poll every 5 seconds (video generation takes longer)
if status == "Success":
output = result["output"]
print("Video URL:", output["resultUrl"])
print("Cover Image:", output["cover"])
else:
print("Task failed")
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/imageToVideo/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('Video URL:', result.output.resultUrl);
console.log('Cover Image:', result.output.cover);
console.log('Resolution:', result.output.width, 'x', result.output.height);
} else {
console.log('Task failed');
}
break;
}
// Wait 5 seconds before next poll (video tasks take longer)
await new Promise(resolve => setTimeout(resolve, 5000));
}
}
pollResult(1234567890123456789n);
📤 การตอบสนอง#
การตอบกลับสำเร็จ (งานเสร็จสิ้น — โหมดมาตรฐาน)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Success",
"waitNumber": 0,
"percentage": 100,
"input": {
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "720p",
"modelType": "Flash",
"prompt": "Gentle camera zoom in with soft lighting"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/video_result.mp4",
"cover": "https://cdn.ideal.house/output/video_cover.jpg",
"width": 1280,
"height": 720
}
}
}
การตอบกลับสำเร็จ (งานเสร็จสิ้น — โหมดเฟรมแรก-เฟรมสุดท้าย)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Success",
"waitNumber": 0,
"percentage": 100,
"input": {
"imageUrl": "https://example.com/room-day.jpg",
"lastImageUrl": "https://example.com/room-night.jpg",
"duration": 10,
"resolution": "720p",
"modelType": "Flash",
"prompt": "Smooth day to night transition"
},
"output": {
"resultUrl": "https://cdn.ideal.house/output/video_result.mp4",
"cover": "https://cdn.ideal.house/output/video_cover.jpg",
"width": 1280,
"height": 720
}
}
}
การตอบสนอง (งานกำลังประมวลผล / อยู่ในคิว)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Processing",
"waitNumber": 2,
"percentage": 30,
"input": {
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "720p",
"modelType": "Flash"
},
"output": null
}
}
การตอบสนอง (งานล้มเหลว)
{
"code": 0,
"message": "success",
"data": {
"id": 1234567890123456789,
"status": "Failed",
"waitNumber": 0,
"percentage": 0,
"input": {
"imageUrl": "https://example.com/room.jpg",
"duration": 5,
"resolution": "720p",
"modelType": "Flash"
},
"output": null
}
}
ฟิลด์คำตอบ
| ฟิลด์ | ประเภท | คำอธิบาย |
|---|---|---|
id | long | ตัวระบุเฉพาะของงาน |
status | string | สถานะงานปัจจุบัน (ดู สถานะงาน) |
waitNumber | integer | จำนวนงานที่อยู่ข้างหน้าในคิว (0 หมายถึงกำลังประมวลผล) |
percentage | integer | ร้อยละความคืบหน้าของงาน (0–100) |
input | object | พารามิเตอร์อินพุตเดิมของงาน |
input.imageUrl | string | URL ของภาพต้นฉบับ (เฟรมแรกในโหมดเฟรมแรก-เฟรมสุดท้าย) |
input.lastImageUrl | string | URL ของภาพเฟรมสุดท้าย (มีเฉพาะในโหมดเฟรมแรก-เฟรมสุดท้าย) |
input.duration | integer | ระยะเวลาวิดีโอในหน่วยวินาที (5 หรือ 10) |
input.resolution | string | ความละเอียดวิดีโอ (480p, 720p หรือ 1080p) |
input.modelType | string | ประเภทโมเดลที่ใช้ (Flash หรือ Base) |
input.generateAudio | boolean | ว่าการสร้างเสียงถูกเปิดใช้งานหรือไม่ (เฉพาะโมเดล Base) |
input.prompt | string | ข้อความพรอมป์ต (หากระบุ) |
output | object | ผลลัพธ์การสร้าง (พร้อมใช้งานเฉพาะเมื่อ status เป็น Success) |
output.resultUrl | string | URL ไปยังไฟล์วิดีโอที่สร้างแล้ว |
output.cover | 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., การรวมกันของ modelType, resolution หรือ duration ไม่ถูกต้อง | ตรวจสอบว่าพารามิเตอร์ที่จำเป็นทั้งหมดถูกระบุและจัดรูปแบบอย่างถูกต้อง |
5002 | API_KEY_INVALID | คีย์ API ไม่ถูกต้องหรือไม่พบ | ตรวจสอบว่าเฮดเดอร์ APIKEY มีอยู่และค่าถูกต้อง |
9010 | SCAN_TEXT_ERROR | คำสั่งข้อความไม่ผ่านการตรวจสอบเนื้อหา | แก้ไขคำสั่งเพื่อลบเนื้อหาที่อ่อนไหวหรือห้ามใช้ |
9038 | PROHIBITED_CONTENT | ภาพผลลัพธ์ที่สร้างมามีเนื้อหาที่ห้ามใช้ | ปรับคำสั่ง/สไตล์/อินพุตและลองใหม่ |
9051 | COINS_NOT_ENOUGH | เหรียญ/เครดิตไม่เพียงพอ | เติมเครดิตในบัญชีของคุณแล้วลองใหม่ |
📄 สำหรับรายการรหัสข้อผิดพลาด API ทั่วไปทั้งหมด ดู อ้างอิงรหัสข้อผิดพลาด