MAGI-2
curl --request POST \
--url https://apistable.ai/api/v1/tasks/create_task \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "magi-2",
"input": {
"mode": "text_to_video",
"prompt": "A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": true
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'magi-2',
input: {
mode: 'text_to_video',
prompt: 'A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.',
resolution: '1080p',
aspect_ratio: '16:9',
duration: 5,
generate_audio: true
}
})
};
fetch('https://apistable.ai/api/v1/tasks/create_task', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.ai/api/v1/tasks/create_task"
payload = {
"model": "magi-2",
"input": {
"mode": "text_to_video",
"prompt": "A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": True
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": 200,
"msg": "success",
"data": {
"task_id": "<string>"
}
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}MAGI
MAGI-2
通过文本、首尾帧或多模态参考生成 4–30 秒 1080p 带声音视频。
POST
/
api
/
v1
/
tasks
/
create_task
MAGI-2
curl --request POST \
--url https://apistable.ai/api/v1/tasks/create_task \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "magi-2",
"input": {
"mode": "text_to_video",
"prompt": "A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": true
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'magi-2',
input: {
mode: 'text_to_video',
prompt: 'A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.',
resolution: '1080p',
aspect_ratio: '16:9',
duration: 5,
generate_audio: true
}
})
};
fetch('https://apistable.ai/api/v1/tasks/create_task', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://apistable.ai/api/v1/tasks/create_task"
payload = {
"model": "magi-2",
"input": {
"mode": "text_to_video",
"prompt": "A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": True
}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"code": 200,
"msg": "success",
"data": {
"task_id": "<string>"
}
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}{
"code": 123,
"msg": "<string>",
"data": null
}参数与输入模式
请求必填model 与 input,省略的可选字段使用模型默认值。完整字段定义见下方 Body 区域。
| 请求场景 | 必填 input 字段 |
|---|---|
| 文生视频 | mode: "text_to_video"、prompt(不可传素材字段) |
| 首尾帧图生视频 | mode: "image_to_video"、prompt、first_frame_url(可选 last_frame_url) |
| 多模态参考生视频 | mode: "reference_to_video"、prompt,以及参考图/视频/音频至少一项 |
特殊模式
- 多模态参考限制与指代:
reference_to_video最多 10 图、5 视频(单段 2–30 秒且合计 ≤30 秒)、5 音频(单段 2–30 秒且合计 ≤30 秒);提示词可用@Image1/@Video1/@Audio1指代,建议使用英文。
使用场景示例
将下方示例提交至POST /api/v1/tasks/create_task,并将提示词与素材链接替换为你的内容。
{
"model": "magi-2",
"input": {
"mode": "text_to_video",
"prompt": "A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.",
"resolution": "1080p",
"aspect_ratio": "16:9",
"duration": 5,
"generate_audio": true
}
}
{
"model": "magi-2",
"input": {
"mode": "image_to_video",
"prompt": "Smooth tracking shot as twilight lanterns illuminate the quiet courtyard.",
"first_frame_url": "https://cdn.example.com/start.jpg",
"last_frame_url": "https://cdn.example.com/end.jpg",
"aspect_ratio": "16:9",
"duration": 8
}
}
{
"model": "magi-2",
"input": {
"mode": "reference_to_video",
"prompt": "Follow the character appearance from @Image1, camera movement from @Video1, and ambient rhythm from @Audio1.",
"reference_image_urls": [
"https://cdn.example.com/character.jpg"
],
"reference_video_urls": [
"https://cdn.example.com/camera.mp4"
],
"reference_audio_urls": [
"https://cdn.example.com/ambience.mp3"
],
"aspect_ratio": "16:9",
"duration": 6
}
}
通过查询任务或 callback_url(Webhook 验签)获取结果,提交错误见创建任务。生成链接保留 14 天;超过 24 小时未完成的任务自动失败且不扣费。
在线试用与价格
每个成功的 1080p 视频分别按请求的整数duration(4–30 秒)统一计费;输出文件可能略长约 0.24 秒且不额外收费。音频、画幅与参考素材不加价,失败项扣费为 0。余额查询见积分余额。| 分辨率 | 积分 / 秒 | 价格 / 秒 |
|---|---|---|
1080p(全部模式) | 16.0 | 折合 ≈ **$0.073** · 常规 $0.080 |
在线试用
在工作台测试文生、首尾帧与多模态参考模式。
查看价格
查看 1080p 每秒单价与充值折合价。
授权
登录 APIstable 后,在 API Key 管理 创建并复制密钥。
每次调用都要在 HTTP 请求头传入:
Authorization: Bearer YOUR_API_KEY
将 YOUR_API_KEY 替换为你创建的 API Key。
请求体
application/json
回调
POST{$request.body#/callback_url}Webhook
请求体
application/json
任务成功或失败后,APIstable 向创建任务时传入的 callback_url 发送 JSON POST。验签后返回 HTTP 2xx 确认接收。
用 data.status 判断生成结果。成功时为 succeeded,生成视频链接位于 data.result.urls。全部失败时为 failed,data.result 为 null,data.message 提供失败原因。
签名和去重使用 X-APIstable-Signature、X-APIstable-Timestamp 和 X-APIstable-Event-Id。详见 Webhook 安全与验签。
Webhook 请求体示例
{
"code": 200,
"msg": "success",
"data": {
"task_id": "c6adbc82-8b9a-4d6f-8b60-1114c8c4aafb",
"model": "magi-2",
"status": "succeeded",
"created_at": "2026-11-25T08:30:00.000Z",
"completed_at": "2026-11-25T08:45:00.000Z",
"duration": 900000,
"charged_credits": 80,
"message": "",
"input": "{\"mode\":\"text_to_video\",\"prompt\":\"A wooden train glides along a misty coastal viaduct at golden hour, ocean waves crashing below.\",\"resolution\":\"1080p\",\"aspect_ratio\":\"16:9\",\"duration\":5,\"generate_audio\":true}",
"result": {
"urls": [
"https://cdn.example.com/generated/video.mp4"
],
"items": [
{
"id": "e7aacd19-819a-4747-bbbf-46fb6f2995a5",
"urls": [
"https://cdn.example.com/generated/video.mp4"
],
"last_frame_url": null,
"draft": false,
"draft_expires_at": null
}
]
}
}
}
响应
2XX
已接收 Webhook。