API 文档

灵动数智人 RESTful API v1.0

快速开始

欢迎使用灵动数智人API!通过我们的API,您可以轻松地将数字人视频生成功能集成到您的应用中。

1. 获取 API Key

首先,您需要在API Keys 管理页面创建一个API Key。

2. 认证方式

所有API请求都需要在HTTP Header中包含您的API Key:

X-API-Key: ld_your_api_key_here

3. 基础URL

https://your-domain.com/api/v1

生成视频

POST /generate

创建一个数字人视频生成任务。

请求参数

参数名 类型 必填 说明
source File 源文件(图片或视频)
audio File 音频文件
type String 类型:image 或 video
callback_url String 回调地址,任务完成后通知

请求示例

curl -X POST https://your-domain.com/api/v1/generate \ -H "X-API-Key: ld_your_api_key_here" \ -F "source=@avatar.jpg" \ -F "audio=@speech.mp3" \ -F "type=image" \ -F "callback_url=https://your-domain.com/callback"

响应示例

{ "success": true, "task_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "duration": 10.5, "credits_used": 105, "status": "pending", "message": "任务已提交" }

查询任务状态

GET /task/:taskId

查询视频生成任务的状态。

请求示例

curl -X GET https://your-domain.com/api/v1/task/a1b2c3d4-e5f6-7890 \ -H "X-API-Key: ld_your_api_key_here"

响应示例

{ "task_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "status": "completed", "type": "image", "duration": 10.5, "credits_used": 105, "download_url": "/api/v1/download/a1b2c3d4-e5f6-7890", "created_at": "2026-01-13T10:30:00.000Z", "completed_at": "2026-01-13T10:35:00.000Z" }

状态说明

  • pending - 等待处理
  • processing - 正在生成
  • completed - 已完成
  • failed - 生成失败

下载视频

GET /download/:taskId

下载生成的视频文件。

请求示例

curl -X GET https://your-domain.com/api/v1/download/a1b2c3d4-e5f6-7890 \ -H "X-API-Key: ld_your_api_key_here" \ -o output.mp4

回调通知

当您在创建任务时提供了 callback_url,任务完成后我们会向该地址发送POST请求。

回调数据格式

{ "task_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "status": "completed", "download_url": "/api/v1/download/a1b2c3d4-e5f6-7890" }

请确保您的回调地址能够接收POST请求,并返回状态码200表示接收成功。

错误码说明

状态码 说明
200 请求成功
400 请求参数错误
401 未授权(API Key无效)
403 权限不足(积分不足等)
404 资源不存在
500 服务器内部错误

SDK 与示例

我们提供了多种语言的SDK和示例代码,帮助您快速集成:

Python 示例

import requests api_key = "ld_your_api_key_here" headers = {"X-API-Key": api_key} # 创建任务 files = { 'source': open('avatar.jpg', 'rb'), 'audio': open('speech.mp3', 'rb') } data = { 'type': 'image', 'callback_url': 'https://your-domain.com/callback' } response = requests.post( 'https://your-domain.com/api/v1/generate', headers=headers, files=files, data=data ) result = response.json() task_id = result['task_id'] print(f"任务ID: {task_id}") # 查询状态 status_response = requests.get( f'https://your-domain.com/api/v1/task/{task_id}', headers=headers ) print(status_response.json())

技术支持

如有任何API使用问题,欢迎联系我们:

微信:26868586