圖片生成接口支持文生圖、圖生圖、圖片編輯等多種功能。通過統一的API接口,您可以調用 Gemini、豆包 Seedream、GPT Image、通義千問等多個主流圖像生成模型。
Bearer Token,如 Bearer sk-xxxxxxxxxx
請求參數
模型標識,支持的模型包括:
- 通義千問系列:
qwen-image-plus、qwen-image-edit-plus 等
- GPT Image 系列:
gpt-image-1 等
- 豆包 Seedream 系列:
doubao-seedream-3-0-t2i-250415、doubao-seedream-4-0-250828、doubao-seedream-4-5-251128、doubao-seededit-3-0-i2i-250628 等
- Gemini 系列:
gemini-2.5-flash-image (Nano Banana)、gemini-3-pro-image-preview (Nano Banana Pro) 等
響應格式:b64_json 或 url注意:不同模型對 response_format 的支持情況不同:
- 通義千問系列:支持
b64_json 和 url
- GPT Image 系列:僅支持
b64_json 格式
- 豆包 Seedream 系列:通常返回 URL 連結
- Gemini 系列:僅支持
b64_json 格式
基礎示例
Gemini
豆包 Seedream
GPT Image
通義千問
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"prompt": "一隻可愛的橙色小貓坐在花園裡,陽光明媚,高質量攝影",
"size": "16:9",
"quality": "high",
"n": 1,
"temperature":1.1,
"top_p":0.95,
"response_format": "b64_json",
"image_size": "2K",
"mime_type": "image/png",
"response_modalities": "image"
}'
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image",
"size": "16:9",
"quality": "high",
"image_size": "3K",
"temperature":1.1,
"top_p":0.95,
"response_format": "b64_json",
"contents": [
{
"role": "user",
"parts": [
{"text": "根據這張圖生成一張俯瞰廣州塔的圖片"},
{"image": "data:image/png;base64,iVBORw0KGgoAAxxxx..."}
]
}
]
}'
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-4-0-250828",
"prompt": "一隻可愛的橙色小貓坐在花園裡,陽光明媚,高質量攝影",
"size": "2048x2048",
"watermark": false,
"seed": 12345,
"optimize_prompt_options": {
"mode": "standard"
}
}'
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "doubao-seedream-4-0-250828",
"prompt": "將這張圖片改成油畫風格",
"size": "2048x2048",
"watermark": false,
"seed": 12345,
"contents": [
{
"role": "user",
"parts": [
{"image": "data:image/png;base64,iVBORw0KGgoAAxxxx..."},
{"text": "將這張圖片改成油畫風格"}
]
}
]
}'
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "一隻可愛的橙色小貓坐在花園裡,陽光明媚,高質量攝影",
"size": "1024x1024",
"quality": "high",
"n": 1
}'
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-1",
"prompt": "將這張圖片改成油畫風格",
"size": "1024x1024",
"quality": "high",
"input_fidelity": "medium",
"n": 1,
"image": "data:image/png;base64,iVBORw0KGgoAAxxxx..."
}'
curl -X POST "https://console.mixroute.io/v1/images/generations" \
-H "Authorization: Bearer sk-xxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-plus",
"input": {
"messages": [
{
"role": "user",
"content": [
{
"text": "一副典雅莊重的對聯懸掛於廳堂之中,房間是個安靜古典的中式佈置"
}
]
}
]
},
"parameters": {
"negative_prompt": "1",
"prompt_extend": true,
"seed": "4",
"watermark": true
}
}'
{
"code": 200,
"msg": "操作成功",
"data": {
"data": [
{
"url": "",
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQA...",
"revised_prompt": ""
}
],
"created": 1757320007
}
}
模型專用參數
豆包 Seedream
圖片尺寸,支持的尺寸取決於模型版本:
- doubao-seedream-4.0/4.5:
2048x2048、2304x1728 等(2K/4K)
- doubao-seedream-3.0:
1024x1024、1152x864 等
引導係數,建議範圍:1.0-10.0,默認:2.5
sequential_image_generation
組圖功能開關:"disabled"(默認)或 "auto"
GPT Image
圖片尺寸:1024x1024、1024x1536、1536x1024。默認:1024x1024
圖片質量:"high"、"medium"、"low"
輸入保真度:"auto"、"high"、"medium"、"low"
Gemini
寬高比:1:1、3:2、2:3、3:4、4:3、4:5、5:4、9:16、16:9、21:9
輸出格式:image/png(默認)、image/jpeg
支持的模型
Gemini 系列
| 模型名稱 | 核心能力 |
|---|
gemini-2.5-flash-image (Nano Banana) | 文生圖、圖生圖、多圖融合、多輪對話 |
gemini-3-pro-image-preview (Nano Banana Pro) | 更高質量輸出、文生圖、圖生圖、多圖融合 |
豆包 Seedream 系列
| 模型名稱 | 核心能力 |
|---|
doubao-seedream-3-0-t2i-250415 | 文生圖、隨機種子控制、引導係數調節 |
doubao-seedream-4-0-250828 | 文生圖、圖生圖、多圖融合、組圖功能、2K/4K |
doubao-seedream-4-5-251128 | 文生圖、圖生圖、多圖融合、組圖功能、提示詞優化 |
doubao-seededit-3-0-i2i-250628 | 圖片編輯、風格遷移 |
GPT Image 系列
| 模型名稱 | 核心能力 |
|---|
gpt-image-1 | 文生圖、圖生圖、多圖融合、質量選擇 |
gpt-image-1-mini | 更低成本、更快速度 |
通義千問系列
| 模型名稱 | 核心能力 |
|---|
qwen-image-plus | 文生圖、中英文文本渲染、提示詞擴展 |
qwen-image-edit-plus | 圖片編輯、風格遷移、物體增刪 |
常見問題
不同模型支持的格式不同:
- 通義千問:JPEG、JPG、PNG、BMP、TIFF、WEBP,最大 10MB
- GPT Image:JPEG、PNG、GIF、WEBP,最大 10MB
- 豆包 Seedream 4.x:JPEG、PNG、WEBP、BMP、TIFF、GIF,最大 10MB
- Gemini:PNG、JPEG、JPG、WEBP,最大 7MB
圖片URL的有效期約為24小時。建議在收到響應後立即下載保存,或上傳到您自己的存儲服務。
- GPT Image:使用
n 參數控制生成數量(1-10張)
- 豆包 Seedream 4.x:使用組圖功能生成 1-4 張
- 通義千問:每次請求生成1張,如需多張請發起多個並發請求
curl --request POST \
--url https://console.mixroute.io/v1/images/generations \
--header 'Authorization: Bearer sk-xxxxxxxxxx' \
--header 'Content-Type: application/json' \
--data '{
"model": "seedream-4.0-base",
"prompt": "一隻可愛的橙色小貓坐在花園裡",
"size": "1024x1024",
"n": 1
}'
{
"created": 1709459123,
"data": [
{
"url": "https://example.com/generated-image.png",
"revised_prompt": "一隻可愛的橙色小貓坐在花園裡"
}
]
}