Ideal House
跳转到主要内容

图像转视频 API 文档#

基础 URL: https://api.ideal.house
版本: v1
更新时间: 2026-03-25


📖 概述#

图像转视频 API 允许您从单张源图像生成 AI 视频,或通过指定首帧末帧图像来控制生成视频的开头和结尾。该工作流为异步流程,包含两个步骤:

  1. 创建任务 — 提交您的图像、模型类型、时长和分辨率,然后获得一个 taskId
  2. 轮询结果 — 使用 taskId 查询任务状态并获取生成的视频。

🔐 认证#

所有 API 请求必须使用 API Key 进行认证。

在请求头中包含您的 API Key:

头部
APIKEYyour_api_key_here

⚠️ 妥善保管您的 API Key。 请勿在客户端代码或公开仓库中暴露它。


💰 积分扣除#

[!WARNING] 🪙 积分会根据所选的 modelTyperesolutionduration 以及 generateAudio 是否启用,在任务创建成功时扣除。如果任务最终失败,扣除的积分将自动退还到您的账户。
积分不足将返回错误码 9051。📄 请参阅 积分扣除说明

Flash 模型modelType: "Flash",默认):

分辨率时长扣除积分
480p5s10 积分
480p10s20 积分
720p5s20 积分
720p10s40 积分
1080p5s40 积分
1080p10s80 积分

Base 模型modelType: "Base"generateAudio: false):

分辨率时长扣除积分
480p5s8 积分
480p10s16 积分
720p5s16 积分
720p10s32 积分
1080p5s32 积分
1080p10s64 积分

带音频的 Base 模型modelType: "Base"generateAudio: true):

分辨率时长扣除积分
480p5s16 积分
480p10s32 积分
720p5s32 积分
720p10s64 积分
1080p5s64 积分
1080p10s128 积分

📌 API 接口端点#


1. 创建图像转视频任务#

创建一个新的 AI 图像转视频生成任务,并返回用于轮询的唯一 taskId

接口端点

纯文本
POST /api/v1/imageToVideo/generate

请求头

头部是否必需说明
APIKEY✅ 是您的 API 认证密钥
Content-Type✅ 是application/json

请求体

字段类型是否必需说明
imageUrlstring✅ 是源图像的 URL。在首尾帧模式下,此字段作为首帧
durationinteger✅ 是视频时长(秒)。枚举值:510
resolutionstring✅ 是视频输出分辨率。枚举值:480p720p1080p
modelTypestring❌ 可选用于生成的模型类型。枚举值:FlashBase。默认为 Flash
generateAudioboolean❌ 可选是否为视频生成背景音频。仅在 modelTypeBase 时适用。默认为 false
promptstring❌ 可选用于引导视频生成风格和运动的文本提示
lastImageUrlstring❌ 可选末帧图像的 URL。提供后启用首尾帧模式:视频将从 imageUrl(首帧)过渡到 lastImageUrl(末帧)

💡 首尾帧模式: 如果提供了 lastImageUrl,则 API 将生成一段从首帧图像(imageUrl)平滑过渡到末帧图像(lastImageUrl)的视频,让您精确控制视频的开头和结尾。

🖼️ 图像要求: 首帧及可选的末帧图像须使用 JPG/JPEG、PNG 或 WebP 格式。每张图像大小不得超过 20 MB,尺寸范围为 128 × 128 px6,000 × 6,000 px(含边界值)。超出最大像素尺寸的图像会被按比例缩放至 6,000 × 6,000 px 以内后再进行处理。图像 URLs 必须能被 API 服务器直接访问。


模型类型

说明
Flash默认。 生成速度更快,输出质量高
Base备选模型 — 支持可选的 AI 音频生成(generateAudio

时长选项

说明
55 秒视频
1010 秒视频

分辨率选项

说明
480p标准清晰度 — 处理速度更快
720p高清晰度 — 输出质量更高
1080p全高清 — 最高质量输出

📥 请求示例#

cURL
bash
# 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)
java
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)
python
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)
javascript
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();

📤 响应#

成功响应

json
{
  "code": 0,
  "message": "success",
  "data": 1234567890123456789
}
字段类型说明
codeinteger0 表示成功
messagestring响应消息
datalong用于轮询结果的任务 ID

2. 获取任务结果#

获取之前创建的图像转视频任务的当前状态和输出。

接口端点

纯文本
GET /api/v1/imageToVideo/result

请求头

头部是否必需说明
APIKEY✅ 是您的 API 认证密钥

查询参数

参数类型是否必需说明
taskIdlong✅ 是创建任务接口返回的任务 ID

📥 请求示例#

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

📤 响应#

成功响应(任务完成 — 标准模式)

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

成功响应(任务完成 — 首尾帧模式)

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

响应(任务处理中 / 队列中)

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

响应(任务失败)

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

响应字段

字段类型说明
idlong任务唯一标识符
statusstring当前任务状态(参见任务状态
waitNumberinteger队列中排在您前面的任务数(0 表示正在处理中)
percentageinteger任务完成百分比(0–100
inputobject任务的原始输入参数
input.imageUrlstring源图像 URL(首尾帧模式下的首帧)
input.lastImageUrlstring末帧图像 URL(仅在首尾帧模式下存在)
input.durationinteger视频时长(秒)(510
input.resolutionstring视频分辨率(480p720p1080p
input.modelTypestring使用的模型类型(FlashBase
input.generateAudioboolean是否启用了音频生成(仅限 Base 模型)
input.promptstring文本提示(如有提供)
outputobject生成结果(仅在 statusSuccess 时可用)
output.resultUrlstring生成视频的 URL
output.coverstring视频封面/缩略图图像的 URL
output.widthinteger视频宽度(像素)
output.heightinteger视频高度(像素)

📊 任务状态#

状态说明
Unprocessed任务已创建但尚未开始
Processing任务正在处理中
Success任务已成功完成 — 视频输出已可用
Failed任务因错误而失败

3-5 秒轮询一次。详见 API 任务限制


❌ 错误响应#

所有错误响应均采用相同的 JSON 结构:

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

错误码参考#

代码名称说明建议操作
1001FAILED请求失败(通用错误)查看 message 字段获取具体错误详情
1003INTERNAL_ERROR服务器内部错误短暂延迟后重试;如持续发生请联系技术支持
1011PARAM_ERROR请求参数错误 — e.g.、无效的 modelTyperesolutionduration 组合确认所有必需参数均已提供且格式正确
5002API_KEY_INVALID无效或缺失的 API Key确保 APIKEY 头部存在且值正确
9010SCAN_TEXT_ERROR文本提示未通过内容审核修改提示以移除敏感或禁止内容
9038PROHIBITED_CONTENT生成输出图像包含禁止内容调整提示/风格/输入后重试
9051COINS_NOT_ENOUGH积分不足充值账户积分后重试

📄 如需查阅完整的常用 API 错误码列表,请参考 错误码参考