接口说明
图像生成(千问 Qwen-Image-2512)
shell
POST https://api.scnet.cn/api/llm/v1/images/generations1.功能介绍
千问文生图接口(Qwen-Image-2512)用于根据输入的文本提示词同步生成图像。请求返回时直接携带生成图像的访问地址,无需轮询任务状态。
调用流程:
- 调用图像生成接口,在请求体中传入提示词及生成参数。
- 从响应的
output.results中获取生成图像的访问地址。
2.图像生成
shell
POST https://api.scnet.cn/api/llm/v1/images/generations2.1 请求参数
Header 参数
| 名称 | 类型 | 必填 | 示例值 | 描述 |
|---|---|---|---|---|
| Content-Type | string | 是 | application/json | \ |
| Authorization | string | 是 | Bearer <API Key> | \ |
Body 参数
| 名称 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| model | string | 是 | \ | 调用模型的名称。例如:Qwen-Image-2512。 |
| input | object | 是 | \ | 输入给模型用于生成图像的信息。 |
| parameters | object | 否 | \ | 图像生成参数配置,包括尺寸、出图数量、去噪步数、CFG引导比例等。 |
input 参数说明
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| prompt | string | 是 | 正向提示词,用来描述期望在图像画面中出现的内容。 |
parameters 参数说明
| 名称 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| size | string | 否 | 1024x1024 | 输出图像分辨率,格式为 宽x高 或 宽*高(* 会自动转换为 x),例如 1024x1024。未传 size 时若同时传入 width 与 height,则按 width x height 拼接;三者都未传时使用默认值 1024x1024。 |
| n | integer | 否 | 1 | 出图数量,取值范围 [1, 6],超出范围会被自动截断到该区间。 |
| negative_prompt | string | 否 | \ | 反向提示词,用来描述不希望在图像画面中出现的内容,对画面进行限制。示例值:low quality, blurry, distorted。 |
| num_inference_steps | integer | 否 | \ | 去噪步数,步数越多细节越丰富但耗时更长,具体范围以上游模型限制为准。 |
| true_cfg_scale | double | 否 | \ | True CFG 引导比例,数值越大越贴合提示词描述。 |
| seed | integer | 否 | \ | 随机种子,取值范围 [0, 2147483647]。传入相同种子与参数可复现生成结果。 |
2.2 响应参数
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| request_id | string | 是 | 请求唯一标识。可用于请求明细溯源和问题排查。 |
| output | object | 是 | 任务输出信息。 |
| output.task_id | string | 是 | 本次生成任务 ID。 |
| output.task_status | string | 是 | 任务状态。同步返回成功时为 succeeded。 |
| output.submit_time | string | 否 | 任务提交时间。 |
| output.end_time | string | 否 | 任务完成时间。 |
| output.results | array | 否 | 生成图像的访问地址列表,元素均为可直接访问的图片 URL。 |
| usage | object | 否 | 本次请求的用量信息。 |
| usage.image_count | integer | 否 | 生成图像数量。 |
| usage.resolution | string | 否 | 生成图像的分辨率,格式为 `宽x高`。 |
2.3 请求示例
cURL请求示例
shell
curl -X POST 'https://api.scnet.cn/api/llm/v1/images/generations' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer <API Key>' \
--data-raw '{
"model": "Qwen-Image-2512",
"input": {
"prompt": "一只坐着的橘黄色的猫,表情愉悦,活泼可爱,逼真准确"
},
"parameters": {
"negative_prompt": "low quality, blurry, distorted",
"size": "1024x1024",
"n": 1,
"num_inference_steps": 50,
"true_cfg_scale": 4.0,
"seed": 2468
}
}'Python请求示例
python
import requests
url = "https://api.scnet.cn/api/llm/v1/images/generations"
payload = {
"model": "Qwen-Image-2512",
"input": {
"prompt": "一只坐着的橘黄色的猫,表情愉悦,活泼可爱,逼真准确"
},
"parameters": {
"negative_prompt": "low quality, blurry, distorted",
"size": "1024x1024",
"n": 1,
"num_inference_steps": 50,
"true_cfg_scale": 4.0,
"seed": 2468
}
}
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <API Key>"
}
response = requests.post(url, headers=headers, json=payload)
print(response.text)2.4 响应示例
json
{
"request_id": "93181007-6691-9bf8-810d-c04e37959265",
"output": {
"task_id": "2069294934625923074",
"task_status": "succeeded",
"submit_time": "2026-08-07 10:00:00",
"end_time": "2026-08-07 10:00:03",
"results": [
"https://example.com/image-1.png"
]
},
"usage": {
"image_count": 1,
"resolution": "1024x1024"
}
}3.注意事项
- 千问(Qwen-Image-2512)文生图为同步接口,请求返回时直接携带生成图像地址,无需调用任务查询接口。
size支持宽x高或宽*高两种写法,*会被自动转换为x;size与width/height二者择一即可,同时传入时以size为准。- 出图数量
n取值范围为 [1, 6],超出范围将被自动截断到该区间;未传时默认为 1。