主题
创建图片
所有请求均需携带 API Key。基础地址及响应格式见通用约定。
创建图片生成任务
作用:使用配置接口返回的稳定线路编码和模型编码创建图片生成任务。
请求:POST /generation/create/image
Content-Type:application/json
输入参数
表格较宽时,可左右滑动查看完整内容。
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| channel | string | 是 | imageConfig[].channel 返回的稳定线路编码 |
| model | string | 是 | 所选线路 models[].model 返回的稳定模型编码 |
| prompt | string | 是 | 图片生成提示词,最长 5000 字符 |
| aspectRatio | string | 是 | 画幅比例,必须从所选模型 aspectRatios 中选择 |
| quality | string | 是 | 质量/清晰度档位,必须从所选模型 qualities[].quality 中选择 |
| inputImages | array<string> | 否 | 输入参考图片公网 URL 列表,最多 inputImagesMax 条;元素不能为空字符串 |
| n | integer | 是 | 生成数量,必须满足所选模型 n 能力;当前仅支持 1 |
可运行的测试请求
先设置环境变量 AISTARSLAB_API_KEY。该请求不扣生成积分。
bash
curl 'https://api.video.aistarslab.com/openapi/generation/create/image' \
-H "Authorization: Bearer $AISTARSLAB_API_KEY" \
-H 'Content-Type: application/json' \
--data '{"channel":"test","model":"test-image","prompt":"测试生成","aspectRatio":"16:9","quality":"1K","n":1}'正式请求结构示例
这是正式任务的结构示例,模型和素材 URL 须替换为实际可用值。可直接运行的测试请求见上方。
json
{
"channel": "21",
"model": "example-image-model",
"prompt": "一只白色陶瓷杯放在木桌上,柔和自然光,产品摄影",
"aspectRatio": "1:1",
"quality": "1K",
"inputImages": [
"https://example.com/reference.jpg"
],
"n": 1
}返回参数
HTTP 200 且 response.code=0 时,response.data:
表格较宽时,可左右滑动查看完整内容。
| 属性名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| taskId | string | 是 | 任务业务 ID,用于查询状态和结果 |
| type | integer | 是 | 生成类型编码,图片为 1 |
| status | integer | 是 | 任务状态编码 |
| costCredits | integer | 是 | 本次任务实际消耗积分 |
创建响应示例
json
{
"code": 0,
"msg": "success",
"data": {
"taskId": "test_image_example",
"type": 1,
"status": 2,
"costCredits": 0
}
}保存实际返回的 data.taskId,继续查询任务。status=2 表示已受理并执行中,不表示生成已完成。测试查询固定返回成功,真实任务可能等待、执行或失败。