图像转视频 API 文档#
基础 URL:
https://api.ideal.house
版本: v1
更新时间: 2026-03-25
📖 概述#
图像转视频 API 允许您从单张源图像生成 AI 视频,或通过指定首帧和末帧图像来控制生成视频的开头和结尾。该工作流为异步流程,包含两个步骤:
- 创建任务 — 提交您的图像、模型类型、时长和分辨率,然后获得一个
taskId。 - 轮询结果 — 使用
taskId查询任务状态并获取生成的视频。
🔐 认证#
所有 API 请求必须使用 API Key 进行认证。
在请求头中包含您的 API Key:
| 头部 | 值 |
|---|---|
APIKEY | your_api_key_here |
⚠️ 妥善保管您的 API Key。 请勿在客户端代码或公开仓库中暴露它。
💰 积分扣除#
[!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 | ✅ 是 | 视频时长(秒)。枚举值:5、10 |
resolution | string | ✅ 是 | 视频输出分辨率。枚举值:480p、720p、1080p |
modelType | string | ❌ 可选 | 用于生成的模型类型。枚举值: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 | 全高清 — 最高质量输出 |
📥 请求示例#
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 | 用于轮询结果的任务 ID |
2. 获取任务结果#
获取之前创建的图像转视频任务的当前状态和输出。
接口端点
GET /api/v1/imageToVideo/result
请求头
| 头部 | 是否必需 | 说明 |
|---|---|---|
APIKEY | ✅ 是 | 您的 API 认证密钥 |
查询参数
| 参数 | 类型 | 是否必需 | 说明 |
|---|---|---|---|
taskId | long | ✅ 是 | 创建任务接口返回的任务 ID |
📥 请求示例#
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 Key | 确保 APIKEY 头部存在且值正确 |
9010 | SCAN_TEXT_ERROR | 文本提示未通过内容审核 | 修改提示以移除敏感或禁止内容 |
9038 | PROHIBITED_CONTENT | 生成输出图像包含禁止内容 | 调整提示/风格/输入后重试 |
9051 | COINS_NOT_ENOUGH | 积分不足 | 充值账户积分后重试 |
📄 如需查阅完整的常用 API 错误码列表,请参考 错误码参考。