01 概览
H3 是一个全模态视频生成模型,在一次前向里联合生成画面与同步立体声(人声、音效、音乐)。接口为异步:提交任务立即拿到 id,再轮询状态、完成后取件。
/v1/videos 规范设计(响应里 model 字段显示 MiniMax-H3),但由本地 H3 引擎生成。已有 Sora 客户端稍改即可接入。02 鉴权
每个请求(提交/查询/下载)都需在请求头带上 Bearer Token,否则返回 401。Token 校验在 nginx 网关层完成,后端服务只监听内网,外部扫描无法直连。
Authorization: Bearer h3-c7203631286407cd4e86136b11b4ab2e8cc601f5879902ce
03 快速开始
文生视频(t2va),8 步快档,约 2–3 分钟出片。三个必填字段:task、target、prompt。
curl https://h3.yiling.ink/v1/videos \
-H "Authorization: Bearer h3-c72036…901f5879902ce" \
-F task=t2va \
-F 'target={"short_edge":768,"aspect_ratio":"16:9","duration_seconds":5}' \
-F prompt=一只橘猫在钢琴键上散步,阳光洒进房间,轻柔的钢琴声 \
-F num_inference_steps=8 \
-F seed=42
# → {"id":"7932b6bd-…","status":"queued","progress":0, …}
import requests, time
BASE = "https://h3.yiling.ink"
TOKEN = "h3-c7203631286407cd4e86136b11b4ab2e8cc601f5879902ce"
H = {"Authorization": f"Bearer {TOKEN}"}
# 1) 提交任务(multipart 表单)
r = requests.post(f"{BASE}/v1/videos", headers=H, data={
"task": "t2va",
"target": '{"short_edge":768,"aspect_ratio":"16:9","duration_seconds":5}',
"prompt": "一只橘猫在钢琴键上散步,阳光洒进房间",
"num_inference_steps": 8,
"seed": 42,
})
vid = r.json()["id"]
# 2) 轮询直到完成
while True:
s = requests.get(f"{BASE}/v1/videos/{vid}", headers=H).json()
if s["status"] in ("completed", "failed"): break
time.sleep(5)
# 3) 取件:s["inference_time_s"], s["file_paths"], 或 /content 下载
print(s["status"], s["inference_time_s"])
04 端点
辅助端点:GET /health 健康检查 · GET /model_info 模型信息 · GET /openapi.json 完整 schema。
05 请求参数
POST /v1/videos 使用 multipart/form-data。下表为常用字段;标红的三项必填。
核心字段
| 字段 | 类型 | 说明 / 取值 |
|---|---|---|
| task必填 | string | 任务模式:t2va(文生视频)· fl2va(首/尾帧)· ref2va(参考素材) |
| target必填 | json string | 输出规格对象,如 {"short_edge":768,"aspect_ratio":"16:9","duration_seconds":5} |
| prompt必填 | string | 文本描述。支持中英等 11 种语言;含台词时会生成对应人声 |
| num_inference_steps | int | 去噪步数。质量档 50,均衡 20,快档 8(配合 Turbo)。见 预设 |
| seed | int | 随机种子,固定后可复现同一结果 |
| negative_prompt | string | 负向提示,描述不希望出现的内容 |
| guidance_scale | float | CFG 引导强度。蒸馏/Turbo 权重下用 1.0(过高会中止) |
| flow_shift | float | 流匹配偏移。官方 benchmark 视频 12 / 音频 3 |
| num_outputs_per_prompt | int | 同一 prompt 生成多少条(默认 1) |
target 输出规格对象
| 子字段 | 类型 | 取值 |
|---|---|---|
| short_edge | int | 固定 768(模型 shape policy 锁死,传其他值后端直接 400)。size/resolution 仅用于推导比例 |
| aspect_ratio | string | 显式取值为白名单:21:9 · 16:9 · 4:3 · 1:1 · 3:4 · 9:16,或 auto(fl2va=跟随首帧图,连续范围 1:4–4:1;ref2va/t2va=16:9)。网关交付时自动规整为精确比例:16:9 → 1366×768,9:16 → 768×1366,居中裁切不拉伸 |
| duration_seconds | number | 时长,4–15 秒 |
条件输入:conditions(官方推荐,fl2va / ref2va 用)
conditions 是一个 JSON 数组,每个元素声明一件参考素材(与官方 MiniMax-H3 请求格式一致):
"conditions": [
{"role": "keyframe", "type": "image", "uri": "data:image/jpeg;base64,…", "frame_index": 0}, // fl2va 首帧
{"role": "reference", "type": "image", "uri": "https://…/face.png"}, // ref2va 参考图
{"role": "reference", "type": "video", "uri": "data:video/mp4;base64,…"} // ref2va 参考视频
]
| 字段 | 取值 | 说明 |
|---|---|---|
| type | image · video · audio | 媒体格式,仅此三种(实测其他值被拒) |
| role | keyframe · reference | 条件角色:fl2va 用 keyframe(配 frame_index:0=首帧,-1=尾帧);ref2va 一律 reference |
| uri | string | 支持 https:// URL 与 data: Base64 两种 |
<Picture 1>,第 1 个视频 = <Video 1>,第 1 段音频 = <Audio 1>,顺序即 conditions 数组内同类素材的顺序),在 subject_definitions 段落里声明用途。动作迁移(换人做动作)官方写法:
subject_definitions:
<Subject 1> is the person whose appearance comes from <Picture 1>
and whose dance motion comes from <Video 1>.
summary:
[reference generation] The target video shows <Subject 1> performing
the motion of <Video 1> …
retention_analysis:
<Subject 1>: fully_preserved - identity and appearance follow <Picture 1>.
<Video 1> (motion structure): attribute_transfer - the motion is
transferred to <Subject 1>; the original performer is not preserved.
detailed_description:
[Shot 1] …(按官方 Prompt 指南逐镜头描述)
关键 marker:attribute_transfer(特征迁移到另一主体)/ fully_preserved / partially_preserved / weak_reference。完整规则见模型自带 docs/VIDEO_PROMPT_WRITING_GUIDE_ref_en.md。subject_definitions 时不注入):
"conditions": [
{"role": "identity", "type": "image", "uri": "…"}, // 人物身份(别名 subject/face/appearance/character)
{"role": "motion", "type": "video", "uri": "…"}, // 动作驱动(别名 action/drive/driving/pose)
{"role": "voice", "type": "audio", "uri": "…"} // 音色参考(别名 timbre,可选)
]
type 也兼容 reference_image / reference_video / reference_audio 写法(自动转 image/video/audio)。注意:这些用途值直接传给后端会被拒,必须经网关。条件输入:兼容字段(sglang 通用通道,已实测可用)
| 字段 | 类型 | 说明 |
|---|---|---|
| input_reference | file | 上传参考/首帧图片(二进制) |
| reference_url | string | 参考/首帧图片的 URL |
| video_reference | file | 上传参考视频片段(ref2va) |
| video_url / video_path | string | 参考视频的 URL 或服务器路径 |
增强与输出(可选)
| 字段 | 类型 | 说明 |
|---|---|---|
| enable_teacache | bool | 开启时间步缓存加速(近无损,约 1.4×) |
| enable_frame_interpolation | bool | 补帧,配 frame_interpolation_exp / _scale |
| enable_upscaling | bool | 超分,配 upscaling_scale |
| output_quality | string | 输出画质档位 |
| generator_device | string | 默认 cuda |
完整字段(含 fps、num_frames、size、true_cfg_scale、max_sequence_length、extra_body 等)以 GET /openapi.json 为准。
06 三种任务模式
由 task 字段选择。当前服务加载的是 Ref2VA 检查点(+ 官方 ref2v_turbo_4step_v0.1 LoRA,按 8 步推理),支持 ref2va;t2va / fl2va 为 FL2VA 检查点能力,需切换服务(显存无法双开)。带参考图请求请显式传 task=ref2va,否则网关默认推导为 fl2va 会被当前后端拒绝。
| task | 含义 | 输入 | 典型用途 |
|---|---|---|---|
| t2va | 文本 → 音视频 | 仅 prompt | 纯创意生成、有声短片 |
| fl2va | 首/尾帧 → 音视频 | prompt + 1~2 张图 首帧 / 尾帧 / 首尾帧 | 图片动起来、指定开场结尾 |
| ref2va | 参考素材 → 音视频 | prompt + ≤9 图 / ≤3 视频 / ≤3 音频 | 角色一致性、风格/音色参考 |
curl https://h3.yiling.ink/v1/videos \
-H "Authorization: Bearer $TOKEN" \
-F task=fl2va \
-F 'target={"short_edge":768,"aspect_ratio":"16:9","duration_seconds":5}' \
-F prompt=镜头缓缓推近,人物微笑转头 \
-F input_reference=@first_frame.png \
-F num_inference_steps=8
07 响应结构
提交与查询都返回同一个 VideoResponse 对象。关键字段:
| 字段 | 类型 | 说明 |
|---|---|---|
| id | string | 任务唯一 id,轮询/下载都用它 |
| status | string | queued in progress completed failed |
| progress | int | 进度百分比 0–100 |
| file_paths | array | 生成的 MP4 服务器路径(可多条) |
| url | string | 下载 URL(如提供) |
| inference_time_s | float | 实际生成耗时(秒) |
| peak_memory_mb | float | 显存峰值(MB) |
| size / seconds | string | 交付分辨率(已规整到精确比例)与时长 |
| size_raw | string | 模型原始输出分辨率(规整前,如 1344x768) |
| error | object | 失败时的错误详情 |
{
"id": "7932b6bd-c572-4b0a-b04b-429578587f94",
"status": "completed", "progress": 100,
"size": "1366x768", "seconds": "5.166667",
"inference_time_s": 139.58,
"peak_memory_mb": 36506.0,
"file_paths": ["outputs/7932b6bd-….mp4"]
}
08 异步流程
视频生成耗时以分钟计,接口设计为异步三段式。提交后客户端无需保持长连接,拿 id 走人,之后轮询即可。
| 步骤 | 调用 | 结果 |
|---|---|---|
| 1 · 提交 | POST /v1/videos | 立即返回 id + queued |
| 2 · 轮询 | GET /v1/videos/{id} | 每 5 秒查一次 status / progress |
| 3 · 取件 | GET /v1/videos/{id}/content | 完成后下载 MP4 |
09 预设与样片
同一 prompt、同一 1344×768 / 5 秒规格,在双 A800 上的实测三档。步数越少越快,画质略降。点卡片播放样片。
质量档 · 50 步
均衡档 · 20 步
快档 · 8 步 Turbo
num_inference_steps=50。样片链接:h3.yiling.ink/samples/10 能力与限制
| 项目 | 规格 |
|---|---|
| 输出时长 | 4–15 秒 |
| 宽高比 | 21:9 / 16:9 / 4:3 / 1:1 / 3:4 / 显式白名单 21:9 / 16:9 / 4:3 / 1:1 / 3:4 / 9:16 + auto;auto 跟随参考图为连续范围(1:4–4:1)。参考图居中裁切、不拉伸 |
| 分辨率 | 短边 768。模型原生 32px 对齐(16:9 原生 1344×768),网关交付统一规整为精确比例(1366×768 / 768×1366);2K 需 H3-Regenerate-2K |
| 帧率 | 24 FPS |
| 音频 | 32 kHz 立体声,与画面联合生成 |
| 台词语言 | 稳定支持 11 种:中/英/日/韩/法/德/意/西/葡/俄/阿 |
| 并发 | 同时 1 路(串行),异步队列;吞吐 ≈ 20 条/小时(快档) |
| 硬件 | 2× NVIDIA A800 80GB,denoiser 张量并行,驱动 580 / CUDA 13 |
11 任务队列(持久化网关)
所有请求经一层持久化网关(FastAPI + SQLite,systemd 守护)进入 H3 引擎。任务落库,服务/服务器重启也不丢,中断的自动续跑。
轮询 GET /v1/videos/{id} 会多返回:queue_ahead(排队时前面还有几个)、created_at、完成后 url(下载地址)。GET /health 返回实时队列深度 {status, queued, running, backend}。
id 返回,之后轮询——不要用一个连接死等一条视频。生成再久、排队再长都不占连接、不超时。12 接入 New API
本接口兼容 New API(newapi.pro)的 OpenAI 视频(Sora)格式,可直接加为一个渠道。
| 配置项 | 值 |
|---|---|
| 渠道类型 | OpenAI Video(Sora 格式) |
| Base URL | https://h3.yiling.ink |
| 密钥 Key | 上文的 Bearer Token |
| 模型 | MiniMax-H3 |
零改兼容:task / target 自动补全
H3 特有的 task、target 在网关侧可选,不传会自动推导,所以标准 Sora 请求直接能用:
| 缺省字段 | 自动推导规则 |
|---|---|
| task | 默认 t2va;带图片 input_reference 时自动 fl2va |
| target | 由 size(如 1280x720 → short_edge 720 / 16:9)+ seconds 推出 |
| num_inference_steps | 默认 8(快档) |
纯 Sora 客户端要覆盖 H3 参数,放 metadata(JSON 字符串):metadata={"task":"fl2va","num_inference_steps":8,"guidance_scale":1.0}。
curl https://h3.yiling.ink/v1/videos \
-H "Authorization: Bearer $TOKEN" \
-F prompt=a red sports car on a coastal road at sunset \
-F model=MiniMax-H3 -F size=1280x720 -F seconds=5
# 无需 task/target,网关自动补全 → 正常生成