跳到內容
開放式卡斯塔利控制台

圖片

gemini-2.5-flash-image API

透過 Modelflare 使用本頁顯示的確切型號 ID 呼叫 gemini-2.5-flash-image。

使用準確的型號 ID gemini-2.5-flash-image。模型欄位必須與此頁面完全相符。

油漆晶片卡從架子上抬起並分類到紫羅蘭色到橙色的漸變牆中。

範例輸出gemini-2.5-flash-imagePOST /v1beta/models/gemini-2.5-flash-image:generateContent

參數: size=2Kratio=16:9

提示詞: The paint aisle of a hardware store, fluorescent tubes and rows of colour chip cards. A woman in a chrome puffer coat has just run one hand along the rack. Every card she touched has lifted off its peg and the whole aisle is filling with them, thousands of paper chips turning in the air and sorting themselves into a single smooth gradient wall from deep violet to hot orange. Cold fluorescent ambient, one hard warm slash of light from the end of the aisle. Wide low camera down the aisle, paper edges catching the light, film grain, no text.

產生此樣本的請求
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "The paint aisle of a hardware store, fluorescent tubes and rows of colour chip cards. A woman in a chrome puffer coat has just run one hand along the rack. Every card she touched has lifted off its peg and the whole aisle is filling with them, thousands of paper chips turning in the air and sorting themselves into a single smooth gradient wall from deep violet to hot orange. Cold fluorescent ambient, one hard warm slash of light from the end of the aisle. Wide low camera down the aisle, paper edges catching the light, film grain, no text."
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "2K"
}
}
}

將 Modelflare API 金鑰與 https://modelflare.dev 結合使用。網關入口點是POST /v1/models/{model}:generateContent。

HTTP
Authorization: Bearer YOUR_MODELFLARE_API_KEY
終端機視窗bash
curl "https://modelflare.dev/v1/models/gemini-2.5-flash-image:generateContent" \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "A white cat runs through a neon-lit street in the rain"}]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"], "imageConfig": {"aspectRatio": "16:9", "imageSize": "1K"}}
}'

Gemini影像模型使用原生contents和generationConfig;編輯傳送文字指令和inline_data在同一個parts[]中。

Gemini 影像模型使用原生 Gemini generateContent。將文字和參考影像放在同一個contents[].parts[]中;影像使用 inline_data。請勿將這些模型發送到 /v1/images/generations、/v1/images/edits 或 OpenAI /v1/responses。 imageSize 枚舉是特定於模型的,如下所示。

場 必填 註釋
contents[].parts[].text 是 文字提示或編輯指令
contents[].parts[].inline_data 否 Base64影像資料與MIME類型
contents[].parts[].inline_data.mime_type 否 image/jpeg / image/png / image/webp
contents[].parts[].inline_data.data 否 Base64編碼的參考影像內容
generationConfig.responseModalities 是 ["IMAGE"] 或 ["TEXT", "IMAGE"]
generationConfig.imageConfig.aspectRatio 否 1:1 / 4:3 / 3:4 / 16:9 / 9:16
generationConfig.imageConfig.imageSize 否 1K / 2K / 4K

Gemini 2.5 Flash Image 支援 1K、2K 和 4K 以及 1:1、4:3、3:4、16:9 和 9:16。官方文件沒有發布參考圖像計數上限,因此網關沒有添加本地上限。

將編輯指令和參考影像放在同一個contents[].parts[]中。 inline_data.data為Base64影像內容;請勿將 Gemini 影像模型傳送至 OpenAI 影像或 Responses 端點。

終端機視窗bash
curl "https://modelflare.dev/v1/models/gemini-2.5-flash-image:generateContent" \
-H "Authorization: Bearer YOUR_MODELFLARE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role": "user", "parts": [
{"text": "Keep the subject and lighting, but replace the background with a misty pine forest."},
{"inline_data": {"mime_type": "image/jpeg", "data": "BASE64_IMAGE_DATA"}}
]}],
"generationConfig": {"responseModalities": ["TEXT", "IMAGE"], "imageConfig": {"aspectRatio": "1:1", "imageSize": "1K"}}
}'

讀取candidates[].content.parts[];不要假設每個部分都是圖像,因為回應可能同時包含文字和圖像部分。

場 註釋
candidates[].content.parts[].inline_data 產生的影像MIME類型與Base64數據
candidates[].content.parts[].text 請求 TEXT 時返回文字標題
candidates[].finishReason 完成或安全原因
usageMetadata 服務返回時的輸入/輸出令牌使用情況

Modelflare 保留 gemini-2.5-flash-image 的原生 Gemini 響應形狀並保留可用的影像部分。

來自本機 Gemini 請求的欄位錯誤、大小/比率限制和安全拒絕仍然是與 Gemini 相容的錯誤回應。網關不會將它們重寫為 OpenAI Images 回應。

此頁面涵蓋 Modelflare 模型產生和編輯呼叫。搜尋或地圖豐富、語音管理和元素庫管理是此公共模型呼叫表面之外的資源 API,並且不是必需的請求欄位。

此模型使用按呼叫計費。請參閱 型號定價頁面 ,以了解當前客戶價格、參考標價和完整規格。

媒體合約 · v1

合約 ID: media.gemini-2-5-flash-image.v1適配器: image.gemini.native.v1@v1指紋: 240c1369048275e3ae3ec16db479ebda38b31af481c1ca118c04ae0f23d66ead

官方來源: Google

合約參數

意圖字段控制項選項
sizeselect1K / 2K / 4K
ratioselect1:1 / 4:3 / 3:4 / 16:9 / 9:16

支援的功能

  • allowed_values · size · 1K, 2K, 4K
  • allowed_values · ratio · 1:1, 4:3, 3:4, 16:9, 9:16

結構化請求範例

text

意圖

{
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "ratio": "1:1",
  "size": "1K"
}

提供者請求

{
  "contents": [
    {
      "parts": [
        {
          "text": "A red paper kite over a quiet harbour at dusk."
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "1K"
    },
    "responseModalities": [
      "TEXT",
      "IMAGE"
    ]
  },
  "systemInstruction": {
    "parts": [
      {
        "text": "Generate an image for the user's request. If details are missing, choose reasonable defaults and still return an image. Do not ask clarifying questions."
      }
    ]
  }
}

reference

意圖

{
  "prompt": "A red paper kite over a quiet harbour at dusk.",
  "ratio": "1:1",
  "size": "1K"
}

提供者請求

{
  "contents": [
    {
      "parts": [
        {
          "text": "A red paper kite over a quiet harbour at dusk."
        },
        {
          "inline_data": {
            "data": "AAAA",
            "mime_type": "image/png"
          }
        }
      ],
      "role": "user"
    }
  ],
  "generationConfig": {
    "imageConfig": {
      "aspectRatio": "1:1",
      "imageSize": "1K"
    },
    "responseModalities": [
      "TEXT",
      "IMAGE"
    ]
  },
  "systemInstruction": {
    "parts": [
      {
        "text": "Generate an image for the user's request. If details are missing, choose reasonable defaults and still return an image. Do not ask clarifying questions."
      }
    ]
  }
}