跳转到主要内容
POST
/
v1
/
videos
/
generations
curl --request POST \
  --url https://api.apimart.ai/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "Omni-Flash-Ext",
    "prompt": "a girl is dancing happily in a sunny garden",
    "duration": 10,
    "resolution": "1080p",
    "aspect_ratio": "9:16"
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KS1H7ZYSJWH1N779S2FSHTKA"
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://docs.apimart.ai/llms.txt

Use this file to discover all available pages before exploring further.

curl --request POST \
  --url https://api.apimart.ai/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "Omni-Flash-Ext",
    "prompt": "a girl is dancing happily in a sunny garden",
    "duration": 10,
    "resolution": "1080p",
    "aspect_ratio": "9:16"
  }'
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01KS1H7ZYSJWH1N779S2FSHTKA"
    }
  ]
}

认证

Authorization
string
必填
所有接口均需要使用 Bearer Token 进行认证。获取 API Key:访问 API Key 管理页面 获取您的 API Key。使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY

请求参数

model
string
必填
视频生成模型名称,固定为 Omni-Flash-Ext
prompt
string
必填
视频内容描述。建议详细描述场景、人物、动作、环境、镜头运动、画面风格和音频提示。示例:"a girl is dancing happily in a sunny garden"
duration
integer
默认值:"6"
视频时长,单位为秒。仅支持:46810
传入 57 等其他时长会返回 invalid_duration 错误。
resolution
string
默认值:"720p"
视频分辨率,不区分大小写。可选值:
  • 720p
  • 1080p
  • 4k
传入其他分辨率会返回 invalid_resolution 错误。
aspect_ratio
string
默认值:"16:9"
视频宽高比,用于控制横屏或竖屏。常用值:
  • 16:9 - 横屏
  • 9:16 - 竖屏
默认值:16:9
size
string
兼容字段,含义与 aspect_ratio 相同。若同时传入,建议保持与 aspect_ratio 一致。
image_urls
array<url>
参考图片 URL 数组。可不传、传 1 张或传 3 张:
  • 不传或空数组:文生视频
  • 1 张图片:单图生视频
  • 3 张图片:参考图融合
支持公网可访问的图片 URL,也支持 data:image/...;base64,... 形式的 Base64 图片。
不支持 2 张图的首尾帧模式。传入 2 张图片会返回 unsupported_image_count 错误。4 张及以上未实测验证,不建议使用。

响应

code
integer
响应状态码,成功时为 200
data
array
返回任务数组。

查询任务结果

视频生成为异步任务。提交后会返回 task_id,使用 获取任务状态 接口查询生成进度和结果。
cURL
curl --request GET \
  --url https://api.apimart.ai/v1/tasks/task_01KS1H7ZYSJWH1N779S2FSHTKA \
  --header 'Authorization: Bearer <token>'
建议提交后等待 5-10 秒再开始查询,后续每 5-10 秒轮询一次。单个任务通常约 3-5 分钟完成。

成功结果示例

{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "completed",
    "progress": 100,
    "created": 1779246294,
    "completed": 1779246534,
    "actual_time": 240,
    "estimated_time": 600,
    "cost": 0.4,
    "result": {
      "videos": [
        {
          "url": ["https://cdn.example.com/videos/abc.mp4"],
          "expires_at": 1779332760
        }
      ]
    }
  }
}

失败结果示例

{
  "code": 200,
  "data": {
    "id": "task_01KS1H7ZYSJWH1N779S2FSHTKA",
    "status": "failed",
    "progress": 100,
    "created": 1779246294,
    "completed": 1779246534,
    "actual_time": 240,
    "estimated_time": 600,
    "cost": 0,
    "error": {
      "message": "invalid duration 7, must be one of 4/6/8/10",
      "code": "task_failed"
    }
  }
}

使用场景

场景 1:文生视频

{
  "model": "Omni-Flash-Ext",
  "prompt": "a beautiful sunset over the ocean with seagulls flying",
  "duration": 6,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}

场景 2:单图生视频

{
  "model": "Omni-Flash-Ext",
  "prompt": "make the character smile and slowly turn around, cinematic camera motion",
  "duration": 6,
  "resolution": "1080p",
  "aspect_ratio": "9:16",
  "image_urls": ["https://example.com/character.jpg"]
}

场景 3:3 张参考图融合

{
  "model": "Omni-Flash-Ext",
  "prompt": "a creative scene combining these elements with smooth camera motion",
  "duration": 10,
  "resolution": "1080p",
  "aspect_ratio": "9:16",
  "image_urls": [
    "https://example.com/scene.jpg",
    "https://example.com/character.jpg",
    "https://example.com/product.jpg"
  ]
}

场景 4:4K 短视频

{
  "model": "Omni-Flash-Ext",
  "prompt": "close-up of a hummingbird hovering in front of a red flower",
  "duration": 4,
  "resolution": "4k",
  "aspect_ratio": "16:9"
}

错误码

HTTP错误类型含义处理建议
400invalid_request_errormodel 不是 Omni-Flash-Extprompt 为空或 JSON 格式错误检查请求体
400invalid_durationduration 不是 46810改成支持的时长
400invalid_resolutionresolution 不是 720p1080p4k改成支持的分辨率
400unsupported_image_countimage_urls 数量不受支持,常见于传入 2 张图改成 0、1 或 3 张图片
401authentication_errorToken 无效检查 Bearer Token
402payment_required账户余额不足充值后重试
429rate_limit_error触发限流降低并发或稍后重试
任务失败时,任务查询接口会在 data.error 中返回失败原因。常见原因包括上游配额暂时耗尽、内容审核未通过或上游超时。