Skip to content

接口说明

图像生成(千问 Qwen-Image-2512)

shell
POST https://api.scnet.cn/api/llm/v1/images/generations

1.功能介绍

千问文生图接口(Qwen-Image-2512)用于根据输入的文本提示词同步生成图像。请求返回时直接携带生成图像的访问地址,无需轮询任务状态。

调用流程:

  • 调用图像生成接口,在请求体中传入提示词及生成参数。
  • 从响应的 output.results 中获取生成图像的访问地址。

2.图像生成

shell
POST https://api.scnet.cn/api/llm/v1/images/generations

2.1 请求参数

Header 参数
名称类型必填示例值描述
Content-Typestringapplication/json\
AuthorizationstringBearer <API Key>\
Body 参数
名称类型必填默认值描述
modelstring\调用模型的名称。例如:Qwen-Image-2512。
inputobject\输入给模型用于生成图像的信息。
parametersobject\图像生成参数配置,包括尺寸、出图数量、去噪步数、CFG引导比例等。
input 参数说明
名称类型必填描述
promptstring正向提示词,用来描述期望在图像画面中出现的内容。
parameters 参数说明
名称类型必填默认值描述
sizestring1024x1024输出图像分辨率,格式为 宽x高宽*高* 会自动转换为 x),例如 1024x1024。未传 size 时若同时传入 width 与 height,则按 width x height 拼接;三者都未传时使用默认值 1024x1024。
ninteger1出图数量,取值范围 [1, 6],超出范围会被自动截断到该区间。
negative_promptstring\反向提示词,用来描述不希望在图像画面中出现的内容,对画面进行限制。示例值:low quality, blurry, distorted。
num_inference_stepsinteger\去噪步数,步数越多细节越丰富但耗时更长,具体范围以上游模型限制为准。
true_cfg_scaledouble\True CFG 引导比例,数值越大越贴合提示词描述。
seedinteger\随机种子,取值范围 [0, 2147483647]。传入相同种子与参数可复现生成结果。

2.2 响应参数

名称类型必填描述
request_idstring请求唯一标识。可用于请求明细溯源和问题排查。
outputobject任务输出信息。
output.task_idstring本次生成任务 ID。
output.task_statusstring任务状态。同步返回成功时为 succeeded。
output.submit_timestring任务提交时间。
output.end_timestring任务完成时间。
output.resultsarray生成图像的访问地址列表,元素均为可直接访问的图片 URL。
usageobject本次请求的用量信息。
usage.image_countinteger生成图像数量。
usage.resolutionstring生成图像的分辨率,格式为 `宽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高宽*高 两种写法,* 会被自动转换为 xsizewidth/height 二者择一即可,同时传入时以 size 为准。
  • 出图数量 n 取值范围为 [1, 6],超出范围将被自动截断到该区间;未传时默认为 1。