腾讯混元图像创建接口 - AI 图像生成 - QuickRouter API 中转接口
▼
Authorization
在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
概述
官方文档:https://cloud.tencent.com/document/product/266/126240
请求参数
Header 参数
Authorization
string
可选
示例: Bearer {{YOUR_API_KEY}} Content-Type
string
可选
示例: application/json
Body 参数 application/json
model_name
string
必需
模型名称。取值: GEM:Gemini; Qwen:千问。 Hunyuan:混元。 示例值:GEM
model_version
string
必需
模型版本。取值: 当 ModelName 是 GEM,可选值为 2.5、3.0; 当 ModelName 是 Qwen,可选值为 0925; 当 ModelName 是 Hunyuan,可选值为 3.0; 示例值:2.5
prompt
string
可选
提示词 必需
file_infos
array [object]
可选
type
string
可选
输入的视频文件类型。取值有: File:点播媒体文件; Url:可访问的 URL; 示例值:File
file_id
string
可选
图片文件的媒体文件 ID,即该文件在云点播上的全局唯一标识符,在上传成功后由云点播后台分配。可以在 视频上传完成事件通知 或 云点播控制台 获取该字段。当 Type 取值为 File 时,本参数有效。 说明: 1. 推荐使用小于7M的图片; 2. 图片格式的取值为:jpeg,jpg, png, webp。 示例值:3704211***509819
url
string
可选
可访问的文件 URL。当 Type 取值为 Url 时,本参数有效。 说明: 1. 推荐使用小于7M的图片; 2. 图片格式的取值为:jpeg,jpg, png, webp。 示例值:https://test.com/1.png
text
string
可选
输入图片的描述信息,用于帮助模型理解图片。仅GEM 2.5、GEM 3.0 有效。 示例值:任务背景:这是需要翻新的主建筑(图1),不得改变其几何结构。
negative_prompt
string
可选
要阻止模型生成图片的提示词。
enhance_prompt
string
可选
是否自动优化提示词。开启时将自动优化传入的 Prompt,以提升生成质量。取值有: Enabled:开启; Disabled:关闭;
output_config
object
可选
生图任务的输出媒体文件配置。
storage_mode
string
可选
存储模式。取值有: Permanent:永久存储,生成的图片文件将存储到云点播,可在事件通知中获取到 FileId; Temporary:临时存储,生成的图片文件不会存储到云点播,可在事件通知中获取到临时访问的 URL; 默认值:Temporary
resolution
string
可选
生成图片的分辨率。可选值为 720P、1080P、2K、4K、1024x1024、2048x2048、2304x1728、2496x1664、2560x1440、3024x1296、4096x4096、4694x3520、4992x3328、5404x3040、6198x2656,其中使用模型 Jimeng 时,推荐通过 Prompt 指定图片分辨率和宽高比。 示例值:1024x1024
aspect_ratio
string
可选
指定所生成图片的宽高比。 当 ModelName 是 GEM,可选值是 1:1、3:2、2:3、3:4、4:3、4:5、5:4、9:16、16:9 和 21:9; 当 ModelName 是 Qwen、Jimeng,则暂不支持,其中 Jimeng 会结合 Prompt意图、参考图片尺寸,由模型智能判断输出图片的宽高比。 示例值:16:9
person_generation
string
可选
是否允许人物或人脸生成。取值有: AllowAdult:允许生成成人; Disallowed:禁止在图片中包含人物或人脸; 示例值:AllowAdult
input_compliance_check
string
可选
是否开启输入内容的合规性检查。取值有: Enabled:开启; Disabled:关闭; 示例值:Enabled
output_compliance_check
string
可选
是否开启输出内容的合规性检查。取值有: Enabled:开启; Disabled:关闭; 示例值:Enabled
session_id
string
可选
用于去重的识别码,如果三天内曾有过相同的识别码的请求,则本次的请求会返回错误。最长 50 个字符,不带或者带空字符串表示不做去重。 示例值:mysession
session_context
string
可选
来源上下文,用于透传用户请求信息,音画质重生完成回调将返回该字段值,最长 1000 个字符。 示例值:mySessionContext
tasks_priority
string
可选
任务的优先级,数值越大优先级越高,取值范围是 -10 到 10,不填代表 0。 示例值:10
ext_info
string
可选
保留字段,特殊用途时使用。 示例值:myextinfo { "model_name": "GEM", "model_version": "3.0", "file_infos": [ { "type": "file", "file_id": "387702299774574677", "url": "", "text": "原始图片的描述信息" } ], "prompt": "convert this image to anime style", "negative_prompt": "blur, distorted", "enhance_prompt": "Enabled", "output_config": { "storage_mode": "Temporary", "resolution": "1080P", "aspect_ratio": "1:1", "person_generation": "AllowAdult", "input_compliance_check": "Enabled", "output_compliance_check": "Enabled" }, "session_id": "image-task-67890", "session_context": "{\"user_id\": \"123\", \"scene\": \"profile_picture\"}", "tasks_priority": 10, "ext_info": "" } 请求
示例
{
"model_name": "GEM",
"model_version": "3.0",
"file_infos": [
{
"type": "file",
"file_id": "387702299774574677",
"url": "",
"text": "原始图片的描述信息"
}
],
"prompt": "convert this image to anime style",
"negative_prompt": "blur, distorted",
"enhance_prompt": "Enabled",
"output_config": {
"storage_mode": "Temporary",
"resolution": "1080P",
"aspect_ratio": "1:1",
"person_generation": "AllowAdult",
"input_compliance_check": "Enabled",
"output_compliance_check": "Enabled"
},
"session_id": "image-task-67890",
"session_context": "{\"user_id\": \"123\", \"scene\": \"profile_picture\"}",
"tasks_priority": 10,
"ext_info": ""
}
请求示例代码
curl --location --request POST 'https://api.quickrouter.ai/tencent-vod/v1/aigc-image' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"model_name": "GEM",
"model_version": "3.0",
"file_infos": [
{
"type": "file",
"file_id": "387702299774574677",
"url": "",
"text": "原始图片的描述信息"
}
],
"prompt": "convert this image to anime style",
"negative_prompt": "blur, distorted",
"enhance_prompt": "Enabled",
"output_config": {
"storage_mode": "Temporary",
"resolution": "1080P",
"aspect_ratio": "1:1",
"person_generation": "AllowAdult",
"input_compliance_check": "Enabled",
"output_compliance_check": "Enabled"
},
"session_id": "image-task-67890",
"session_context": "{\"user_id\": \"123\", \"scene\": \"profile_picture\"}",
"tasks_priority": 10,
"ext_info": ""
}'
返回响应
响应参数 🟢 200 OK · application/json
status
string
必需
request_id
string
必需
response_url
string
必需
status_url
string
必需
cancel_url
string
必需
logs
null
必需
metrics
object
必需
queue_position
integer
必需
{ "Response": { "TaskId": "251007502-AigcImage***2782aff1e896673f1ft", "RequestId": "f50d7667-72d8-46bb-a7e3-0613588971b6" } }
示例
{
"Response": {
"TaskId": "251007502-AigcImage***2782aff1e896673f1ft",
"RequestId": "f50d7667-72d8-46bb-a7e3-0613588971b6"
}
}
常见错误
- 401 认证失败:检查 API Key 是否正确
- 429 请求限流:降低调用频率或升级套餐
- 500 服务器错误:稍后重试
注意事项
- 请确保 API Key 有足够的余额
- 请求频率受 API 限制,请参考价格页面