以統一的請求格式執行 GPT Image 2, GPT Image 2.5 Flare, GPT Image 2.5 Sunburst, Nano Banana, Nano Banana 2, Nano Banana 2 Lite, Nano Banana 2.1, Nano Banana Pro, Seedream 4.0, Seedream 4.5, Seedream 5.0, Seedream 5 Pro。
使用 /v1/images/generations 依提示詞建立圖片。支援 JSON 格式。
https://api.mlmux.com/v1/images/generations使用 /v1/images/edits 編輯或合成圖片。可於 JSON 中傳送圖片 URL,或透過 multipart 欄位 image 與 mask 上傳檔案。最多可接受 16 張圖片,每張上限 50 MB。
https://api.mlmux.com/v1/images/editscurl https://api.mlmux.com/v1/images/generations \
-H "Authorization: Bearer $MLMUX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "nano-banana-2",
"prompt": "Editorial product photo of a ceramic mug on linen, soft window light",
"aspect_ratio": "4:3",
"resolution": "2K",
"output_format": "png",
"route_mode": "official-cheap"
}'預設為同步請求,並直接在回應中傳回圖片。加入 "async": true 則改為建立非同步任務。
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
model | string | 是 | 下表中的模型 ID。當簡短名稱具唯一性時可省略提供商前綴,例如 gpt-image-2。 |
prompt | string | 是 | 要生成或修改的內容,最多 20,000 個字元。 |
image_urls僅限編輯 | string[] | 是 | 輸入圖片的公開 http(s) URL,依序排列。單張圖片亦可使用 image_url。 |
mask_url僅限編輯 | string | 否 | 遮罩圖片的 URL,適用於支援遮罩編輯的模型。 |
route_mode | string | 否 | official 或 official-cheap。預設使用金鑰的 route mode,次為 official-cheap。 |
resolution | string | 否 | 支援的 Gemini 模型可設定為 1K、2K 或 4K。Nano Banana 與 Nano Banana 2 Lite 無解析度設定。 |
size | string | 否 | GPT Image 與 Seedream 的輸出尺寸,例如 1024x1024、2K 或 auto。 |
aspect_ratio | string | 否 | 例如 1:1、16:9 或 match_input_image。可用值視模型而定。 |
output_format | string | 否 | png、jpg、jpeg 或 webp(若模型支援)。 |
n | integer | 否 | 圖片數量,1 到 4。預設為 1。 |
async | boolean | 否 | 設為 true 會傳回任務 (HTTP 202) 供輪詢,無需等待圖片生成完成。 |
在 model 中填入這些值。可透過 GET /v1/models 查詢您帳號可用的 ID。
| 模型 | 模型 ID |
|---|---|
| GPT Image 2 | openai/gpt-image-2 |
| GPT Image 2.5 Flare | weavy/gpt-image-2.5-flare |
| GPT Image 2.5 Sunburst | weavy/gpt-image-2.5-sunburst |
| Nano Banana | nano-banana |
| Nano Banana 2 | nano-banana-2 |
| Nano Banana 2 Lite | nano-banana-2-lite |
| Nano Banana 2.1 | google/gemini-nano-banana-2.1 |
| Nano Banana Pro | nano-banana-pro |
| Seedream 4.0 | weavy/doubao-seedream-4-0-250828 |
| Seedream 4.5 | weavy/doubao-seedream-4-5-251128 |
| Seedream 5.0 | weavy/doubao-seedream-5-0-260128 |
| Seedream 5 Pro | weavy/doubao-seedream-5-0-pro-260628 |
GPT Image 2、GPT Image 2.5 Flare 與 GPT Image 2.5 Sunburst 目前僅支援在 official 上執行。使用這些模型時請傳送 "route_mode": "official";若未傳送,請求將套用預設的 official-cheap 並導致失敗。
同步請求會傳回 HTTP 200,每張圖片的 URL 位於 data,Token 計數則位於 usage。輸出 URL 由 MLMux 託管;請下載您想保留的檔案。
{
"created": 1767225600,
"data": [
{ "url": "https://.../generated/9f2c....png" }
],
"usage": {
"input_tokens": 18,
"output_tokens": 1120,
"total_tokens": 1138,
"input_tokens_details": { "text_tokens": 18, "image_tokens": 0 }
}
}帶有 "async": true 時,請求會傳回 HTTP 202 及任務物件。輪詢其 poll_url 直到 status 變為 succeeded,生成的圖片即會列於 data 中。
https://api.mlmux.com/v1/images/generations/{task_id}{
"id": "task_7c1e...",
"object": "image.generation.task",
"status": "queued",
"created": 1767225600,
"model": "nano-banana-2",
"api_method": "images.generations.create",
"poll_url": "/v1/images/generations/task_7c1e...",
"progress": 0,
"message": "queued",
"estimated_charge_credits": 0.067
}{
"id": "task_7c1e...",
"object": "image.generation.task",
"status": "succeeded",
"progress": 100,
"message": "completed",
"estimated_charge_credits": 0.067,
"data": [
{ "url": "https://.../generated/7c1e....png" }
]
}圖片編輯任務的輪詢端點為 /v1/images/edits/{task_id}。GET /v1/tasks/{task_id} 則適用於任何任務。