图片创作

提交图片描述和可选参考图片创建异步图片任务,并轮询获取一张或多张图片。

创建图片任务

按外部模型编码创建 text-to-image 任务;输入图片必须属于当前认证用户。

POST/api/liveAiChat/createImage

请求地址:https://api.jiuma.com/api/liveAiChat/createImage

请求参数

参数类型要求说明能力说明
promptstring必填非空图片描述;字数上限见本页实时模型能力表查看
api_model_codestring必填外部图片模型编码,例如 jiuma-image-2.5;必须是当前启用的图片编码查看
ratiostring选填可用比例与所选模式关联;组合和默认值见模型能力表查看
image_generation_modestring选填模式和默认值见模型能力表;仅可使用该模型声明的模式查看
material_orderarray|string选填有序图片素材数组或 JSON 文本,是素材唯一输入;省略或 [] 表示无参考图片,不开放资产库查看
material_order[].typestring必填(提供顺序时)固定为 image—
material_order[].fileIdint|string必填(提供顺序时)本人通过 /file/uploadMedia 上传的有效正整数图片 file_id,按数组顺序处理查看文件上传说明查看
material_order[].namestring选填图片显示名称;不允许视频专属 referenceFrameRole 或资产引用字段—

请求示例

cURL · Bash / macOS / Linux
curl -X POST "https://api.jiuma.com/api/liveAiChat/createImage" \
  -H "X-Secret-Key: <secret_id-secret_key>" \
  -H "Content-Type: application/json" \
  -d '{"api_model_code":"jiuma-image-2.5","prompt":"一只戴帽子的猫","ratio":"1:1"}'

多图排序请求示例

cURL · 文件 ID 须替换为本人上传结果
curl -X POST "https://api.jiuma.com/api/liveAiChat/createImage" \
  -H "X-Secret-Key: <secret_id-secret_key>" \
  -H "Content-Type: application/json" \
  -d '{"api_model_code":"jiuma-image-2.5","prompt":"融合两张图片的构图与色彩","material_order":[{"type":"image","fileId":102},{"type":"image","fileId":101}]}'

响应示例

JSON
{
  "code": 200,
  "message": "request_success",
  "data": {
    "task_id": "12346"
  }
}

关键返回字段

data.task_id
AI 回复消息 ID;创建成功后使用它调用 statusImage。

常见失败原因

模型编码未知、停用或跨媒体类型,提示词为空,图片数量或比例超出模型能力,引用字段非空,额度不足。

查询图片任务状态

只读查询当前用户的图片任务,成功时返回所有有效图片结果。

POST/api/liveAiChat/statusImage

请求地址:https://api.jiuma.com/api/liveAiChat/statusImage

请求参数

参数类型要求说明能力说明
task_idint|string必填createImage 返回的正整数 AI 回复消息 ID;只能查询本人图片任务—

请求示例

cURL · Bash / macOS / Linux
curl -X POST "https://api.jiuma.com/api/liveAiChat/statusImage" \
  -H "X-Secret-Key: <secret_id-secret_key>" \
  -H "Content-Type: application/json" \
  -d '{"task_id":"12346"}'

响应示例

JSON
{
  "code": 200,
  "message": "request_success",
  "data": {
    "task_id": "12346",
    "status": "success",
    "results": [
      {
        "type": "image",
        "url": "https://media.example.com/result.png"
      }
    ],
    "error_code": "",
    "error_message": ""
  }
}

关键返回字段

data.status
pending、processing、success 或 failed。
data.results[].url
授权消息关联的有效图片 URL;可能包含多个结果。
data.error_code/error_message
任务失败时返回受控错误信息。

常见失败原因

task_id 非正整数、任务不存在、任务属于其他用户或媒体类型不匹配;成功消息没有有效文件时返回资源不可用。