跳转到主要内容

接口

MethodEndpointDescription
POST/api/v1/generateTask/ltx-2-19b创建生成任务
GET/api/v1/statusTask/ltx-2-19b查询任务状态

认证

所有请求需在请求头中携带 API 密钥:
Authorization: Bearer YOUR_API_KEY

请求体

{
  "request_type": "async",
  "callback_url": "https://...",
  "provider": "auto",
  "input": {
    "mode": "text-to-video",
    "prompt": "...",
    "resolution": "1080p",
    "duration": 10,
    "aspect_ratio": "16:9",
    "image_urls": ["..."],
    "seed": 12345,
    "loras": [
      {"path": "...", "scale": 1.2}
    ]
  }
}

参数

request_type
string
默认值:"async"
async(轮询)或 callback(webhook)
callback_url
string
回调 URL,当 request_type=callback 时必填(条件必填)
provider
string
默认值:"auto"
路由策略:auto、value 或 official
input
object
必填
模型输入参数
模式选项:
  • text-to-video — 从文字生成视频
  • image-to-video — 从图片生成视频
  • text-to-video-LoRA — 带 LoRA 的文生视频
  • image-to-video-LoRA — 带 LoRA 的图生视频

示例

文生视频
curl -X POST "https://api.apixo.ai/api/v1/generateTask/ltx-2-19b" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video",
      "prompt": "a futuristic city with flying cars at sunset",
      "resolution": "1080p",
      "duration": 10,
      "aspect_ratio": "16:9",
      "seed": 54248617
    }
  }'
带 LoRA 的图生视频
curl -X POST "https://api.apixo.ai/api/v1/generateTask/ltx-2-19b" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "callback",
    "callback_url": "https://your-server.com/callback",
    "provider": "official",
    "input": {
      "mode": "image-to-video-LoRA",
      "prompt": "make it cinematic with slow pan and dramatic lighting",
      "resolution": "720p",
      "duration": 8,
      "image_urls": ["https://example.com/ref.jpg"],
      "loras": [
        {
          "path": "https://huggingface.co/username/model.safetensors?download=true",
          "scale": 1.2
        }
      ]
    }
  }'
带多 LoRA 的文生视频
curl -X POST "https://api.apixo.ai/api/v1/generateTask/ltx-2-19b" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "request_type": "async",
    "input": {
      "mode": "text-to-video-LoRA",
      "prompt": "anime style magical girl transformation sequence",
      "resolution": "720p",
      "duration": 12,
      "aspect_ratio": "9:16",
      "loras": [
        {"path": "https://huggingface.co/user1/anime_style.safetensors?download=true", "scale": 1.5},
        {"path": "https://huggingface.co/user2/magic_effects.safetensors?download=true", "scale": 0.8}
      ]
    }
  }'

响应

POST /api/v1/generateTask/ltx-2-19b

成功时返回 taskId,用于后续查询状态。 成功:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678"
  }
}
错误:
{
  "code": 400,
  "message": "Insufficient credits",
  "data": null
}

GET /api/v1/statusTask/ltx-2-19b

通过 taskId 查询任务执行状态与结果。
curl -X GET "https://api.apixo.ai/api/v1/statusTask/ltx-2-19b?taskId=task_12345678" \
  -H "Authorization: Bearer YOUR_API_KEY"
成功:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "success",
    "resultJson": "{\"resultUrls\":[\"https://r2.apixo.ai/video.mp4\"]}",
    "createTime": 1767965610929,
    "completeTime": 1767965652317,
    "costTime": 41388
  }
}
失败:
{
  "code": 200,
  "message": "success",
  "data": {
    "taskId": "task_12345678",
    "state": "failed",
    "failCode": "CONTENT_VIOLATION",
    "failMsg": "Content does not meet safety guidelines"
  }
}

状态响应字段

taskId
string
任务唯一标识。
state
string
当前任务状态:pendingprocessingsuccessfailed
resultJson
string
包含 resultUrls 数组的 JSON 字符串。仅在成功时存在。使用 JSON.parse() 解析。
failCode
string
错误码。仅当 statefailed 时存在。详见错误码
failMsg
string
可读的错误信息。仅当 statefailed 时存在。
createTime
integer
任务创建时间戳(Unix 毫秒)。
completeTime
integer
任务完成时间戳(Unix 毫秒)。
costTime
integer
处理耗时(毫秒)。

错误码

CodeDescription
400参数无效或请求错误
401API 密钥无效或缺失
429超过速率限制
Fail CodeDescription
CONTENT_VIOLATION内容违反安全准则
INVALID_IMAGE_URL无法访问提供的图片 URL
INVALID_LORA_URL无法下载 LoRA 模型

速率限制

LimitValue
Requests10000 / minute
Concurrent tasks1000
超出限制返回 429 错误。请稍后重试。

提示

  • 生成时间
    • 480p:约 40-60 秒
    • 720p:约 60-90 秒
    • 1080p:约 90-120 秒
    • LoRA 模式加载增加约 10-20 秒
    • 提交任务后等待 60 秒,再每隔 5 秒轮询
  • 回调模式:视频生成耗时,强烈建议使用 callback 模式。
  • 视频有效期:结果 URL 有效期为 15 天。请及时下载。
  • 内容审核:prompt 需符合内容安全准则。
  • LoRA 微调
    • 加载自定义 LoRA 以实现特定风格或角色
    • LoRA URL 需可公开下载(HuggingFace、Civitai 等)
    • URL 建议包含 ?download=true 等下载参数
    • 最多同时使用 3 个 LoRA
    • scale 控制 LoRA 影响,建议:0.5-2.0
  • 分辨率选择
    • 480p:快速生成,适合预览
    • 720p:质量与速度平衡
    • 1080p:最高质量,适合最终输出
  • 时长:支持 5-20 秒灵活时长,按秒计费。
  • 种子复现:相同 seed + prompt + 参数可复现相同结果。
  • 图片格式image_urls 支持 JPG、PNG、WebP,单张最大 10MB。
  • LoRA 兼容:建议使用视频训练的 LoRA;图像 LoRA 效果可能不佳。

视频生成比图像耗时更长 — 生产环境请使用 callback 模式。结果 URL 15 天后失效,请及时下载重要输出。

相关