部分模型(bailian)以异步方式处理生成。传 task: true 后会拿到 task_id,轮询任务接口确认是否完成。

查询任务

curl https://51kik.com/v1/image/v1/tasks/abc123-task-id \
  -H 'Authorization: Bearer sk-xxxxxxxx'

状态说明

状态含义下一步
pending / running处理中继续轮询
success已完成读取 data 获取图片
failed失败了读取 error 查看原因

成功响应

{
  "task_id": "abc123-task-id",
  "task_status": "success",
  "model": "wanx-v1",
  "created": 1719000000,
  "updated": 1719000020,
  "completed": 1719000020,
  "data": [{ "url": "https://..." }],
  "error": null
}

失败响应

{
  "task_id": "abc123-task-id",
  "task_status": "failed",
  "model": "wanx-v1",
  "created": 1719000000,
  "data": [],
  "error": { "code": "task_failed", "message": "..." }
}

推荐用 SDK

SDK 会自动处理轮询:

const result = await rb.image({
  model: 'wanx-v1',
  prompt: 'a panoramic mountain landscape',
}).task({ pollInterval: 2000 });

超时取消等详情见 SDK 图片生成

注意事项

  • 建议每 2-5 秒轮询一次
  • 不要同时传 task: truestream: true,二选一
  • 设置超时防止无限轮询

相关

阿里云百炼 · SDK 图片生成