1. 概述
使用当前 API Key 已开通的万相图片生成模型生成图片。
baseUrl:https://token.soar.qjclouds.cn/laserEr/00000000/v1completionsPath:/image/generations/{apiType}apiType:TextToImage- 标准地址:
POST {baseUrl}{completionsPath} - 鉴权:
Authorization: Bearer <api_key>
请求地址:https://token.soar.qjclouds.cn/laserEr/00000000/v1/image/generations/TextToImage
2. 鉴权
| Header | 必填 | 说明 |
|---|---|---|
Authorization | 是 | Bearer <api_key> |
Content-Type | 是 | application/json |
3. 请求体
请求体采用阿里云原厂 API JSON 格式。
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 模型编码,以当前 API Key 实际开通的万相图片生成模型为准。 |
input | object | 是 | 模型输入信息。 |
input.messages | array<object> | 是 | 消息列表;仅支持单轮对话,必须且只能包含一个消息对象。 |
input.messages[].role | string | 是 | 消息角色,固定为 user。 |
input.messages[].content | array<object> | 是 | 消息内容列表。 |
input.messages[].content[].text | string | 是 | 正向提示词,描述期望的图片主体、场景、风格和构图。 |
parameters | object | 否 | 图片生成参数。 |
parameters.size | string | 否 | 输出分辨率;示例为 2K,实际可选值以所选模型能力为准。 |
parameters.n | integer | 否 | 生成图片数量,默认 1;具体上限由所选模型决定。 |
parameters.watermark | boolean | 否 | 是否在图片右下角添加“AI Generated”水印;默认 false。 |
parameters.thinking_mode | boolean | 否 | 是否开启思考模式;示例为 true,支持情况以所选模型为准。 |
4. 请求示例
JSON
{
"model": "wan2.7-image-pro-cn",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "一间有着精致窗户的花店,漂亮的木质门,摆放着花朵"
}
]
}
]
},
"parameters": {
"size": "2K",
"n": 1,
"watermark": false,
"thinking_mode": true
}
}5. 响应示例
JSON
{
"output": {
"choices": [
{
"message": {
"role": "assistant",
"content": [
{
"image": "https://dashscope-7c2c.oss-accelerate.aliyuncs.com/1d/92/20260910/d689c36f/66c73580-94d4-40be-ba98-63d992d250e9_0.png?Expires=1789119446&OSSAccessKeyId=LTAI5tPxpiCM2hjmWrFXrym1&Signature=jSe%2BPeJhThfMKz8EGEIx%2BM4%2BjgA%3D",
"type": "image"
}
]
},
"finish_reason": "stop"
}
],
"finished": true
},
"usage": {
"size": "2048*2048",
"image_count": 1,
"input_tokens": 34,
"output_tokens": 2,
"total_tokens": 36
},
"request_id": "e4352308-b542-4032-86a4-f588a7797519"
}响应图片 URL 通常具有有效期,请及时下载或转存。