API Reference
AI 能力 API 文档
能力、接口、请求字段、返回字段、Python 请求代码。
图片
文生图
GPT Image 2gpt-image-2展开收起
输入提示词生成图片,可选择尺寸、比例和模型支持的高级图像参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| size 默认:1536x1024 | 否 | string | 图片尺寸或图片模型输出规格。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| output_format | 否 | png | jpeg | webp | 图片输出格式。 |
| output_compression | 否 | number | 图片压缩率,仅部分格式支持。 |
| background | 否 | opaque | auto | transparent | 图片背景模式,是否支持透明取决于模型。 |
| moderation | 否 | auto | low | 图片安全审核强度。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gpt-image-2",
"prompt": "A clean product photo on a soft studio background.",
"size": "1536x1024",
"n": 1
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)GPT Image 2 Progpt-image-2-pro展开收起
输入提示词生成图片,可选择尺寸、比例和模型支持的高级图像参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| size 默认:1:1 | 否 | string | 图片尺寸或图片模型输出规格。 |
| resolution 默认:1k | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gpt-image-2-pro",
"prompt": "A clean product photo on a soft studio background.",
"size": "1:1",
"resolution": "1k",
"n": 1
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)GPT Image 2 Maxgpt-image-2-max展开收起
输入提示词生成图片,可选择尺寸、比例和模型支持的高级图像参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| size 默认:1024x1024 | 否 | string | 图片尺寸或图片模型输出规格。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| quality | 否 | low | medium | high | auto | 图片质量。 |
| output_format | 否 | png | jpeg | webp | 图片输出格式。 |
| output_compression | 否 | number | 图片压缩率,仅部分格式支持。 |
| background | 否 | opaque | auto | transparent | 图片背景模式,是否支持透明取决于模型。 |
| moderation | 否 | auto | low | 图片安全审核强度。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gpt-image-2-max",
"prompt": "A clean product photo on a soft studio background.",
"size": "1024x1024",
"n": 1
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Banana 2gemini-3.1-flash-image展开收起
输入提示词生成图片,可选择尺寸、比例和模型支持的高级图像参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1K | 否 | string | 图片尺寸或图片模型输出规格。 |
| aspect_ratio 默认:1:1 | 否 | string | 视频或图片比例。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gemini-3.1-flash-image",
"prompt": "A clean product photo on a soft studio background.",
"n": 1,
"size": "1K",
"aspect_ratio": "1:1"
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Nano Banana Progemini-3.0-pro-image展开收起
输入提示词生成图片,可选择尺寸、比例和模型支持的高级图像参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1K | 否 | string | 图片尺寸或图片模型输出规格。 |
| aspect_ratio 默认:1:1 | 否 | string | 视频或图片比例。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gemini-3.0-pro-image",
"prompt": "A clean product photo on a soft studio background.",
"n": 1,
"size": "1K",
"aspect_ratio": "1:1"
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)图片
图片编辑
GPT Image 2gpt-image-2展开收起
输入一张图片和编辑提示词生成新图,部分模型支持 mask 和输出格式控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image | 是 | string | 公网可访问的输入图片 URL。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1536x1024 | 否 | string | 图片尺寸或图片模型输出规格。 |
| mask | 否 | string | 图片编辑 mask URL,PNG 格式。 |
| output_format | 否 | png | jpeg | webp | 图片输出格式。 |
| output_compression | 否 | number | 图片压缩率,仅部分格式支持。 |
| background | 否 | opaque | auto | transparent | 图片背景模式,是否支持透明取决于模型。 |
| moderation | 否 | auto | low | 图片安全审核强度。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
- Mask 素材:PNG,单张不超过 10MB。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
}
files = {
"model": (None, "gpt-image-2"),
"prompt": (None, "A clean product photo on a soft studio background."),
"image": (None, "https://example.com/input.png"),
"n": (None, "1"),
"size": (None, "1536x1024"),
}
response = requests.post(
f"{BASE_URL}/v1/images/async/edits",
headers=headers,
files=files,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)GPT Image 2 Maxgpt-image-2-max展开收起
输入一张图片和编辑提示词生成新图,部分模型支持 mask 和输出格式控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image | 是 | string | 公网可访问的输入图片 URL。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1024x1024 | 否 | string | 图片尺寸或图片模型输出规格。 |
| mask | 否 | string | 图片编辑 mask URL,PNG 格式。 |
| quality | 否 | low | medium | high | auto | 图片质量。 |
| output_format | 否 | png | jpeg | webp | 图片输出格式。 |
| output_compression | 否 | number | 图片压缩率,仅部分格式支持。 |
| background | 否 | opaque | auto | transparent | 图片背景模式,是否支持透明取决于模型。 |
| moderation | 否 | auto | low | 图片安全审核强度。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
- Mask 素材:PNG,单张不超过 10MB。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
}
files = {
"model": (None, "gpt-image-2-max"),
"prompt": (None, "A clean product photo on a soft studio background."),
"image": (None, "https://example.com/input.png"),
"n": (None, "1"),
"size": (None, "1024x1024"),
}
response = requests.post(
f"{BASE_URL}/v1/images/async/edits",
headers=headers,
files=files,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Banana 2gemini-3.1-flash-image展开收起
输入一张图片和编辑提示词生成新图,部分模型支持 mask 和输出格式控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image | 是 | string | 公网可访问的输入图片 URL。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1K | 否 | string | 图片尺寸或图片模型输出规格。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
}
files = {
"model": (None, "gemini-3.1-flash-image"),
"prompt": (None, "A clean product photo on a soft studio background."),
"image": (None, "https://example.com/input.png"),
"n": (None, "1"),
"size": (None, "1K"),
}
response = requests.post(
f"{BASE_URL}/v1/images/async/edits",
headers=headers,
files=files,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Nano Banana Progemini-3.0-pro-image展开收起
输入一张图片和编辑提示词生成新图,部分模型支持 mask 和输出格式控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image | 是 | string | 公网可访问的输入图片 URL。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1K | 否 | string | 图片尺寸或图片模型输出规格。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
}
files = {
"model": (None, "gemini-3.0-pro-image"),
"prompt": (None, "A clean product photo on a soft studio background."),
"image": (None, "https://example.com/input.png"),
"n": (None, "1"),
"size": (None, "1K"),
}
response = requests.post(
f"{BASE_URL}/v1/images/async/edits",
headers=headers,
files=files,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)图片
多图参考生图
GPT Image 2gpt-image-2展开收起
输入多张参考图和提示词生成新图,适合人物、产品、风格或构图参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| size 默认:1536x1024 | 否 | string | 图片尺寸或图片模型输出规格。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gpt-image-2",
"prompt": "A clean product photo on a soft studio background.",
"size": "1536x1024",
"n": 1,
"image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)GPT Image 2 Progpt-image-2-pro展开收起
输入多张参考图和提示词生成新图,适合人物、产品、风格或构图参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| size 默认:1:1 | 否 | string | 图片尺寸或图片模型输出规格。 |
| resolution 默认:1k | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gpt-image-2-pro",
"prompt": "A clean product photo on a soft studio background.",
"size": "1:1",
"resolution": "1k",
"n": 1,
"image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)GPT Image 2 Maxgpt-image-2-max展开收起
输入多张参考图和提示词生成新图,适合人物、产品、风格或构图参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| size 默认:1024x1024 | 否 | string | 图片尺寸或图片模型输出规格。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
| quality | 否 | low | medium | high | auto | 图片质量。 |
| output_format | 否 | png | jpeg | webp | 图片输出格式。 |
| output_compression | 否 | number | 图片压缩率,仅部分格式支持。 |
| background | 否 | opaque | auto | transparent | 图片背景模式,是否支持透明取决于模型。 |
| moderation | 否 | auto | low | 图片安全审核强度。 |
| response_format | 否 | url | b64_json | 图片返回格式。网页接入建议使用 url。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gpt-image-2-max",
"prompt": "A clean product photo on a soft studio background.",
"size": "1024x1024",
"n": 1,
"image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Banana 2gemini-3.1-flash-image展开收起
输入多张参考图和提示词生成新图,适合人物、产品、风格或构图参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1K | 否 | string | 图片尺寸或图片模型输出规格。 |
| aspect_ratio 默认:1:1 | 否 | string | 视频或图片比例。 |
| image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gemini-3.1-flash-image",
"prompt": "A clean product photo on a soft studio background.",
"n": 1,
"size": "1K",
"aspect_ratio": "1:1",
"image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Nano Banana Progemini-3.0-pro-image展开收起
输入多张参考图和提示词生成新图,适合人物、产品、风格或构图参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| n 默认:1 | 否 | number | 生成数量。通常保持 1。 |
| size 默认:1K | 否 | string | 图片尺寸或图片模型输出规格。 |
| aspect_ratio 默认:1:1 | 否 | string | 视频或图片比例。 |
| image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| task_id | string | 异步图片任务 ID。后续用这个 ID 请求 /v1/images/async/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| data.status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| data.data.data[0].url | string | 成功后的图片 URL。response_format=url 时优先读取这个字段。 |
| data.data.data[0].b64_json | string | 成功后的 base64 图片。response_format=b64_json 时读取这个字段。 |
| data.fail_reason | string | 失败原因。生成失败或参数错误时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "gemini-3.0-pro-image",
"prompt": "A clean product photo on a soft studio background.",
"n": 1,
"size": "1K",
"aspect_ratio": "1:1",
"image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/images/async/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/images/async/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["data"]["status"]).lower()
if status in ("success", "succeeded", "completed"):
items = task.get("data", {}).get("data", {}).get("data", [])
first = items[0] if items else {}
result = first.get("url") or first.get("b64_json")
if not result:
raise RuntimeError(f"No image result in response: {task}")
print(result)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
文生视频
HappyHorse 1.0 T2Vhappyhorse-1.0-t2v展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| metadata.resolution 默认:1080P | 否 | string | HappyHorse 视频接口的清晰度。 |
| metadata.ratio 默认:16:9 | 否 | string | HappyHorse 视频接口的视频比例。 |
| metadata.duration 默认:5 | 否 | number | HappyHorse 视频接口的视频时长,单位秒。视频编辑提交时最多传 15 秒,最终扣费以官方 usage.duration 为准。 |
| seed | 否 | number | 随机种子。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "happyhorse-1.0-t2v",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"metadata": {
"resolution": "1080P",
"ratio": "16:9",
"duration": 5
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Wan 2.7 T2Vwan2.7-t2v展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt | 是 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.negative_prompt 默认:low quality, blurry | 否 | string | 模型协议字段,按右侧示例传入。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.ratio 默认:16:9 | 否 | string | Wan 输出画面比例。 |
| parameters.duration 默认:5 | 否 | number | 视频时长,单位秒。Wan 生成类通常为 2-15 秒。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| seed | 否 | number | 随机种子。 |
| watermark | 否 | boolean | 是否添加水印。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-t2v",
"input": {
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"negative_prompt": "low quality, blurry"
},
"parameters": {
"resolution": "720P",
"ratio": "16:9",
"duration": 5,
"prompt_extend": False,
"watermark": False
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-fastvideo-fast-720p展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-fast-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-provideo-pro-720p展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-pro-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Grok Imagine Videogrok-imagine-video展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| preset | 否 | normal | fun | spicy | custom | 视频风格预设。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/grok/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "grok-imagine-video",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion."
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/grok/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flashomni_flash展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| duration 默认:10 | 否 | number | 视频时长,单位秒。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 10
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flash Fastomni_flash-fast展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| duration 默认:10 | 否 | number | 视频时长,单位秒。 |
| seconds 默认:10 | 否 | string | 视频时长,字符串格式,单位秒。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash-fast",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"duration": 10,
"seconds": "10",
"aspect_ratio": "16:9",
"resolution": "720p"
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Kling Videokling-video展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| duration 默认:5 | 否 | number | 视频时长,单位秒。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "kling-video",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "720p"
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Veo 3.1 Fastveo_3_1-fast展开收起
输入提示词生成视频,可选择比例、清晰度、时长和模型支持的视频控制参数。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| enhance_prompt | 否 | boolean | 是否增强提示词。 |
| retry_times | 否 | number | 模型侧失败重试次数。 |
| enable_upsample | 否 | boolean | 是否启用上采样。 |
| veo_fl_close | 否 | boolean | Veo 首尾帧闭合控制。 |
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "veo_3_1-fast",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion."
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
图生视频
HappyHorse 1.0 I2Vhappyhorse-1.0-i2v展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| image | 是 | string | 公网可访问的输入图片 URL。 |
| prompt 默认:A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion. | 否 | string | 生成或编辑提示词。 |
| metadata.resolution 默认:1080P | 否 | string | HappyHorse 视频接口的清晰度。 |
| metadata.duration 默认:5 | 否 | number | HappyHorse 视频接口的视频时长,单位秒。视频编辑提交时最多传 15 秒,最终扣费以官方 usage.duration 为准。 |
| seed | 否 | number | 随机种子。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "happyhorse-1.0-i2v",
"image": "https://example.com/first-frame.png",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"metadata": {
"resolution": "1080P",
"duration": 5
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Wan 2.7 I2Vwan2.7-i2v展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt 默认:A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion. | 否 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.media[] | 是 | object[] | Wan/Kling 媒体数组。Wan 常用类型包括 first_frame、last_frame、first_clip、reference_image、reference_video、video、driving_audio。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| parameters.duration 默认:5 | 否 | number | 视频时长,单位秒。Wan 生成类通常为 2-15 秒。 |
| watermark | 否 | boolean | 是否添加水印。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-i2v",
"input": {
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"media": [
{
"type": "first_frame",
"url": "https://example.com/first-frame.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": False,
"watermark": False,
"duration": 5
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-fastvideo-fast-720p展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
素材要求
- 图片素材:JPEG/PNG,单张不超过 30MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-fast-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/first-frame.png"
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-provideo-pro-720p展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
素材要求
- 图片素材:JPEG/PNG,单张不超过 30MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-pro-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/first-frame.png"
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Grok Imagine Videogrok-imagine-video展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| preset | 否 | normal | fun | spicy | custom | 视频风格预设。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/grok/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "grok-imagine-video",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"image_url": "https://example.com/first-frame.png"
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/grok/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flash I2Vomni_flash_i2v展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| duration 默认:10 | 否 | number | 视频时长,单位秒。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash_i2v",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"image_url": "https://example.com/first-frame.png",
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 10
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flash Fastomni_flash-fast展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| duration 默认:10 | 否 | number | 视频时长,单位秒。 |
| seconds 默认:10 | 否 | string | 视频时长,字符串格式,单位秒。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash-fast",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"image_url": "https://example.com/first-frame.png",
"duration": 10,
"seconds": "10",
"aspect_ratio": "16:9",
"resolution": "720p"
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Kling Videokling-video展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| duration 默认:5 | 否 | number | 视频时长,单位秒。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| images[] | 是 | string[] | 公网可访问的图片 URL 数组。HappyHorse 视频编辑为可选参考图;首尾帧接口按首帧、尾帧顺序传入。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "kling-video",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "720p",
"images": [
"https://example.com/first-frame.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Veo 3.1 Fastveo_3_1-fast展开收起
输入首帧图片和可选提示词生成视频,输出比例通常跟随图片或模型设置。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt 默认:A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion. | 否 | string | 生成或编辑提示词。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| enhance_prompt | 否 | boolean | 是否增强提示词。 |
| retry_times | 否 | number | 模型侧失败重试次数。 |
| enable_upsample | 否 | boolean | 是否启用上采样。 |
| veo_fl_close | 否 | boolean | Veo 首尾帧闭合控制。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "veo_3_1-fast",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"image_url": "https://example.com/first-frame.png"
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
首尾帧视频
Wan 2.7 I2Vwan2.7-i2v展开收起
输入首帧和尾帧两张图,模型在两张边界帧之间生成视频。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt | 是 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.media[] | 是 | object[] | Wan/Kling 媒体数组。Wan 常用类型包括 first_frame、last_frame、first_clip、reference_image、reference_video、video、driving_audio。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| parameters.duration 默认:5 | 否 | number | 视频时长,单位秒。Wan 生成类通常为 2-15 秒。 |
| watermark | 否 | boolean | 是否添加水印。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-i2v",
"input": {
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"media": [
{
"type": "first_frame",
"url": "https://example.com/first-frame.png"
},
{
"type": "last_frame",
"url": "https://example.com/last-frame.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": False,
"watermark": False,
"duration": 5
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Veo 3.1 Fastveo_3_1-fast展开收起
输入首帧和尾帧两张图,模型在两张边界帧之间生成视频。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| images[] | 是 | string[] | 公网可访问的图片 URL 数组。HappyHorse 视频编辑为可选参考图;首尾帧接口按首帧、尾帧顺序传入。 |
| duration 默认:8 | 否 | number | 视频时长,单位秒。 |
| enhance_prompt | 否 | boolean | 是否增强提示词。 |
| retry_times | 否 | number | 模型侧失败重试次数。 |
| enable_upsample | 否 | boolean | 是否启用上采样。 |
| veo_fl_close | 否 | boolean | Veo 首尾帧闭合控制。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "veo_3_1-fast",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"images": [
"https://example.com/first-frame.png",
"https://example.com/last-frame.png"
],
"duration": 8
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
视频续写
Wan 2.7 I2Vwan2.7-i2v展开收起
输入源视频和提示词,从源视频结尾继续生成后续画面,可选尾帧参考图。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt | 是 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.media[] | 是 | object[] | Wan/Kling 媒体数组。Wan 常用类型包括 first_frame、last_frame、first_clip、reference_image、reference_video、video、driving_audio。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| parameters.duration 默认:5 | 否 | number | 视频时长,单位秒。Wan 生成类通常为 2-15 秒。 |
| watermark | 否 | boolean | 是否添加水印。 |
素材要求
- 源视频素材:支持公网 URL 或网页本地上传后生成的公网 URL;建议 MP4,不超过 50MB,建议 2-15 秒。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-i2v",
"input": {
"prompt": "Continue the clip with the subject walking out of the room, natural handheld camera, no subtitles.",
"media": [
{
"type": "first_clip",
"url": "https://example.com/source.mp4"
},
{
"type": "last_frame",
"url": "https://example.com/last-frame.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": False,
"watermark": False,
"duration": 5
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
参考图生视频
HappyHorse 1.0 R2Vhappyhorse-1.0-r2v展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| images[] | 是 | string[] | 公网可访问的图片 URL 数组。HappyHorse 视频编辑为可选参考图;首尾帧接口按首帧、尾帧顺序传入。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| metadata.resolution 默认:1080P | 否 | string | HappyHorse 视频接口的清晰度。 |
| metadata.ratio 默认:16:9 | 否 | string | HappyHorse 视频接口的视频比例。 |
| metadata.duration 默认:5 | 否 | number | HappyHorse 视频接口的视频时长,单位秒。视频编辑提交时最多传 15 秒,最终扣费以官方 usage.duration 为准。 |
| seed | 否 | number | 随机种子。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "happyhorse-1.0-r2v",
"images": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
],
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"metadata": {
"resolution": "1080P",
"ratio": "16:9",
"duration": 5
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Wan 2.7 R2Vwan2.7-r2v展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt | 是 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.media[] | 是 | object[] | Wan/Kling 媒体数组。Wan 常用类型包括 first_frame、last_frame、first_clip、reference_image、reference_video、video、driving_audio。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| parameters.duration 默认:5 | 否 | number | 视频时长,单位秒。Wan 生成类通常为 2-15 秒。 |
| parameters.ratio 默认:16:9 | 否 | string | Wan 输出画面比例。 |
| watermark | 否 | boolean | 是否添加水印。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-r2v",
"input": {
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"media": [
{
"type": "reference_image",
"url": "https://example.com/ref-1.png"
},
{
"type": "reference_image",
"url": "https://example.com/ref-2.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": False,
"watermark": False,
"duration": 5,
"ratio": "16:9"
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-fastvideo-fast-720p展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| extra_images[] | 否 | string[] | 公网可访问的额外参考图 URL 数组。Seedance 最新协议总图片数 image_url + extra_images 最多 9 张。 |
素材要求
- 图片素材:JPEG/PNG,最多 9 张,单张不超过 30MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-fast-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/ref-1.png",
"extra_images": [
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-provideo-pro-720p展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| extra_images[] | 否 | string[] | 公网可访问的额外参考图 URL 数组。Seedance 最新协议总图片数 image_url + extra_images 最多 9 张。 |
素材要求
- 图片素材:JPEG/PNG,最多 9 张,单张不超过 30MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-pro-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/ref-1.png",
"extra_images": [
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Grok Imagine Videogrok-imagine-video展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| images[] | 是 | string[] | 公网可访问的图片 URL 数组。HappyHorse 视频编辑为可选参考图;首尾帧接口按首帧、尾帧顺序传入。 |
| preset | 否 | normal | fun | spicy | custom | 视频风格预设。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/grok/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "grok-imagine-video",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"images": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png",
"https://example.com/ref-3.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/grok/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flash Componentsomni_flash_components展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| reference_image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| duration 默认:10 | 否 | number | 视频时长,单位秒。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash_components",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"reference_image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
],
"aspect_ratio": "16:9",
"resolution": "720p",
"duration": 10
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flash Fastomni_flash-fast展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| reference_image_urls[] | 是 | string[] | 公网可访问的参考图 URL 数组。 |
| duration 默认:10 | 否 | number | 视频时长,单位秒。 |
| seconds 默认:10 | 否 | string | 视频时长,字符串格式,单位秒。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash-fast",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"reference_image_urls": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
],
"duration": 10,
"seconds": "10",
"aspect_ratio": "16:9",
"resolution": "720p"
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Kling Videokling-video展开收起
输入多张参考图和提示词生成视频,适合人物、产品、场景参考。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| duration 默认:5 | 否 | number | 视频时长,单位秒。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| images[] | 是 | string[] | 公网可访问的图片 URL 数组。HappyHorse 视频编辑为可选参考图;首尾帧接口按首帧、尾帧顺序传入。 |
素材要求
- 图片素材:JPEG/PNG/WEBP,单张不超过 10MB,宽高至少 300px。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "kling-video",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"duration": 5,
"aspect_ratio": "16:9",
"resolution": "720p",
"images": [
"https://example.com/ref-1.png",
"https://example.com/ref-2.png"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
图片+音频生视频
sora-sd-2.0-fastvideo-fast-720p展开收起
输入参考图和音频生成视频,适合需要音频驱动画面的场景。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| extra_audios[] | 是 | string[] | 公网可访问的额外音频 URL 数组。Seedance 当前最多 1 条,时长 2-14 秒。 |
素材要求
- 图片素材:JPEG/PNG,最多 9 张,单张不超过 30MB,宽高至少 300px。
- 音频素材:MP3,最多 1 个,单个不超过 15MB,时长 2-14 秒;不支持仅音频提交。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-fast-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/ref-1.png",
"extra_audios": [
"https://example.com/audio.mp3"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-provideo-pro-720p展开收起
输入参考图和音频生成视频,适合需要音频驱动画面的场景。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| extra_audios[] | 是 | string[] | 公网可访问的额外音频 URL 数组。Seedance 当前最多 1 条,时长 2-14 秒。 |
素材要求
- 图片素材:JPEG/PNG,最多 9 张,单张不超过 30MB,宽高至少 300px。
- 音频素材:MP3,最多 1 个,单个不超过 15MB,时长 2-14 秒;不支持仅音频提交。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-pro-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/ref-1.png",
"extra_audios": [
"https://example.com/audio.mp3"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
多模态生视频
Wan 2.7 R2Vwan2.7-r2v展开收起
输入参考图、参考视频和音频生成视频,适合复杂多模态控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt | 是 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.media[] | 是 | object[] | Wan/Kling 媒体数组。Wan 常用类型包括 first_frame、last_frame、first_clip、reference_image、reference_video、video、driving_audio。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| parameters.duration 默认:5 | 否 | number | 视频时长,单位秒。Wan 生成类通常为 2-15 秒。 |
| parameters.ratio 默认:16:9 | 否 | string | Wan 输出画面比例。 |
| watermark | 否 | boolean | 是否添加水印。 |
素材要求
- 参考视频素材:支持公网 URL 或网页本地上传后生成的公网 URL;建议 MP4,单个不超过 50MB,建议 2-15 秒。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-r2v",
"input": {
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"media": [
{
"type": "first_frame",
"url": "https://example.com/first-frame.png"
},
{
"type": "reference_video",
"url": "https://example.com/ref-video.mp4",
"reference_voice": "https://example.com/voice.mp3"
},
{
"type": "reference_image",
"url": "https://example.com/ref-1.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": False,
"watermark": False,
"duration": 5,
"ratio": "16:9"
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-fastvideo-fast-720p展开收起
输入参考图、参考视频和音频生成视频,适合复杂多模态控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| extra_audios[] | 是 | string[] | 公网可访问的额外音频 URL 数组。Seedance 当前最多 1 条,时长 2-14 秒。 |
| extra_videos[] | 是 | string[] | 公网可访问的额外参考视频 URL 数组。Seedance 当前最多 1 条,时长 2-14 秒。 |
素材要求
- 图片素材:JPEG/PNG,最多 9 张,单张不超过 30MB,宽高至少 300px。
- 参考视频素材:MP4,最多 1 个,单个不超过 50MB,时长 2-14 秒。
- 音频素材:MP3,最多 1 个,单个不超过 15MB,时长 2-14 秒;不支持仅音频提交。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-fast-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/ref-1.png",
"extra_audios": [
"https://example.com/audio.mp3"
],
"extra_videos": [
"https://example.com/ref-video.mp4"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)sora-sd-2.0-provideo-pro-720p展开收起
输入参考图、参考视频和音频生成视频,适合复杂多模态控制。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| aspect_ratio 默认:16:9 | 否 | string | 视频或图片比例。 |
| duration 默认:6 | 否 | number | 视频时长,单位秒。 |
| image_url | 是 | string | 公网可访问的首帧图片 URL。 |
| extra_audios[] | 是 | string[] | 公网可访问的额外音频 URL 数组。Seedance 当前最多 1 条,时长 2-14 秒。 |
| extra_videos[] | 是 | string[] | 公网可访问的额外参考视频 URL 数组。Seedance 当前最多 1 条,时长 2-14 秒。 |
素材要求
- 图片素材:JPEG/PNG,最多 9 张,单张不超过 30MB,宽高至少 300px。
- 参考视频素材:MP4,最多 1 个,单个不超过 50MB,时长 2-14 秒。
- 音频素材:MP3,最多 1 个,单个不超过 15MB,时长 2-14 秒;不支持仅音频提交。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "video-pro-720p",
"prompt": "A natural 5-second homestay vlog shot, handheld phone camera, warm daylight, realistic motion.",
"aspect_ratio": "16:9",
"duration": 6,
"image_url": "https://example.com/ref-1.png",
"extra_audios": [
"https://example.com/audio.mp3"
],
"extra_videos": [
"https://example.com/ref-video.mp4"
]
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)视频
视频复刻
Omni Flash Editomni_flash_edit展开收起
输入源视频 URL 和提示词生成复刻或改写视频,可选参考图。网页本地上传会先转成公网 URL 再提交。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input_video | 是 | string | 公网可访问的源视频 URL,用于视频复刻。 |
| messages[] | 是 | object[] | 视频复刻指令数组,格式为 { role: "user", content: "..." }。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| resolution_name 默认:720p | 否 | string | 视频复刻接口需要同时传入的清晰度名称,通常与 resolution 一致。 |
| messages[].content[] | 否 | Array<{ type: string; text?: string; image_url?: { url: string } }> | 可选参考图写入 messages[].content。无参考图时 content 直接传字符串。 |
| aspect_ratio 默认:auto | 否 | auto | 16:9 | 9:16 | 可选输出比例。auto 表示跟随源视频。 |
素材要求
- 源视频素材:MP4,不超过 100MB,时长不超过 10 秒。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash_edit",
"input_video": "https://example.com/source.mp4",
"messages": [
{
"role": "user",
"content": "Recreate this clip in a warmer, more cinematic travel vlog style."
}
],
"resolution": "720p",
"resolution_name": "720p"
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Omni Flash Edit Fastomni_flash_edit-fast展开收起
输入源视频 URL 和提示词生成复刻或改写视频,可选参考图。网页本地上传会先转成公网 URL 再提交。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| video_url | 是 | string | 公网可访问的源视频 URL,和 input_video 传同一个地址用于兼容。 |
| input_video | 是 | string | 公网可访问的源视频 URL,用于视频复刻。 |
| resolution 默认:720p | 否 | string | 清晰度或输出档位,取值以本模型可选项为准。 |
| aspect_ratio 默认:auto | 否 | auto | 16:9 | 9:16 | 可选输出比例。auto 表示跟随源视频。 |
素材要求
- 源视频素材:MP4,不超过 100MB;会先上传为公网 URL 后提交。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/notevideo/{id} 查询结果。 |
| output.task_status | string | 任务初始状态。最终状态以查询接口返回为准。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| output.task_status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| output.media_url | string | 成功后的视频 URL。Sora/Seedance/Omni/Grok 类视频接口优先读取这个字段。 |
| output.video_url / output.result_url | string | 兼容结果字段。部分返回会使用 video_url 或 result_url。 |
| output.fail_reason | string | 失败原因。接口返回时用于定位问题。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "omni_flash_edit-fast",
"prompt": "Recreate this clip in a warmer, more cinematic travel vlog style.",
"video_url": "https://example.com/source.mp4",
"input_video": "https://example.com/source.mp4",
"resolution": "720p"
}
response = requests.post(
f"{BASE_URL}/v1/videos/generations",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = data["output"]["task_id"]
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/notevideo/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str(task["output"]["task_status"]).lower()
if status in ("success", "succeeded", "completed"):
output = task.get("output") or {}
result_url = output.get("media_url") or output.get("video_url") or output.get("result_url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)Wan 2.7 Video Editwan2.7-videoedit展开收起
输入源视频 URL 和提示词生成复刻或改写视频,可选参考图。网页本地上传会先转成公网 URL 再提交。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| input.prompt | 是 | string | Kling 输入对象内的提示词,保持与顶层 prompt 一致。 |
| input.media[] | 是 | object[] | Wan/Kling 媒体数组。Wan 常用类型包括 first_frame、last_frame、first_clip、reference_image、reference_video、video、driving_audio。 |
| parameters.resolution 默认:720P | 否 | string | Wan 输出清晰度,例如 720P / 1080P。 |
| parameters.prompt_extend 默认:false | 否 | boolean | Wan 是否启用提示词改写。 |
| parameters.watermark 默认:false | 否 | boolean | 是否添加水印。 |
| parameters.ratio 默认:16:9 | 否 | string | Wan 输出画面比例。 |
| parameters.audio_setting 默认:auto | 否 | string | Wan 视频编辑音频策略,auto 为自动处理,origin 为尽量保留原视频音频。 |
| watermark | 否 | boolean | 是否添加水印。 |
素材要求
- 源视频素材:支持公网 URL 或网页本地上传后生成的公网 URL;建议 MP4,不超过 50MB,建议 2-15 秒。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "wan2.7-videoedit",
"input": {
"prompt": "Recreate this clip in a warmer, more cinematic travel vlog style.",
"media": [
{
"type": "video",
"url": "https://example.com/source.mp4"
},
{
"type": "reference_image",
"url": "https://example.com/ref-1.png"
}
]
},
"parameters": {
"resolution": "720P",
"prompt_extend": False,
"watermark": False,
"ratio": "16:9",
"audio_setting": "auto"
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)HappyHorse 1.0 Video Edithappyhorse-1.0-video-edit展开收起
输入源视频 URL 和提示词生成复刻或改写视频,可选参考图。网页本地上传会先转成公网 URL 再提交。
接口
请求字段
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| model | 是 | string | 模型 ID,必须使用当前模型的 model 值。 |
| prompt | 是 | string | 生成或编辑提示词。 |
| images[] | 否 | string[] | 公网可访问的图片 URL 数组。HappyHorse 视频编辑为可选参考图;首尾帧接口按首帧、尾帧顺序传入。 |
| metadata.video | 是 | string | 公网可访问的源视频 URL。网页本地上传后也会转成这个 URL 字段提交。 |
| metadata.resolution 默认:1080P | 否 | string | HappyHorse 视频接口的清晰度。 |
| metadata.duration 默认:5 | 否 | number | HappyHorse 视频接口的视频时长,单位秒。视频编辑提交时最多传 15 秒,最终扣费以官方 usage.duration 为准。 |
| metadata.audio_setting 默认:auto | 否 | string | HappyHorse 视频编辑音频策略,auto 为自动处理,origin 为尽量保留原视频音频。 |
| seed | 否 | number | 随机种子。 |
素材要求
- 源视频素材:支持公网 URL 或网页本地上传后生成的公网 URL;MP4/MOV,建议 H.264,不超过 100MB,3-60 秒,短边至少 320px,长边不超过 2160px。编辑时最多取前 15 秒,输出最长 15 秒,最终按官方返回用量计费。
返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| id / task_id / output.task_id | string | 异步视频任务 ID。后续用这个 ID 请求 /v1/videos/{id} 查询结果。 |
| 字段 | 类型 | 说明 |
|---|---|---|
| status | string | 任务状态。成功值通常为 success/succeeded/completed;失败值通常为 failed/failure/error。 |
| video_url / media_url / result_url | string | 成功后的视频 URL。按接口实际返回字段读取。 |
| metadata.url / results[0].url | string | 兼容结果字段。部分视频接口会把最终 URL 放在 metadata 或 results 数组里。 |
| progress | number | string | 任务进度。部分模型返回。 |
Python
import os
import time
import requests
BASE_URL = os.getenv("HAPPYHORSE_BASE_URL", "{{BASE_URL}}")
API_KEY = os.getenv("HAPPYHORSE_API_KEY")
if not API_KEY:
raise RuntimeError("Missing HAPPYHORSE_API_KEY")
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}
json_data = {
"model": "happyhorse-1.0-video-edit",
"prompt": "Recreate this clip in a warmer, more cinematic travel vlog style.",
"images": [
"https://example.com/ref-1.png"
],
"metadata": {
"video": "https://example.com/source.mp4",
"resolution": "1080P",
"duration": 5,
"audio_setting": "auto"
}
}
response = requests.post(
f"{BASE_URL}/v1/videos",
headers=headers,
json=json_data,
timeout=60,
)
response.raise_for_status()
data = response.json()
task_id = (data.get("id") or data.get("task_id") or data.get("output", {}).get("task_id"))
while True:
response = requests.get(
f"{BASE_URL}/v1/videos/{task_id}",
headers=headers,
timeout=30,
)
response.raise_for_status()
task = response.json()
status = str((task.get("status") or task.get("output", {}).get("task_status"))).lower()
if status in ("success", "succeeded", "completed"):
metadata = task.get("metadata") or {}
results = task.get("results") or []
result_url = (
task.get("video_url")
or task.get("media_url")
or task.get("result_url")
or metadata.get("url")
)
if not result_url and results:
result_url = results[0].get("url")
if not result_url:
raise RuntimeError(f"No video result URL in response: {task}")
print(result_url)
break
if status in ("failed", "failure", "error"):
raise RuntimeError(task)
time.sleep(5)