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

圖片

gemini-3.1-flash-lite-image API

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

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

在深夜面台上方用蒸氣編織成珊瑚色和紫羅蘭色的絲帶。

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

參數: ratio=16:9

提示詞: A late-night noodle counter, six stools and a steel pass, rain on the window behind. A cook in an orange quilted jacket has just lifted the lid off a stock pot. The steam is not dispersing: it has gathered into solid braided ribbons of coral and ultraviolet that rope up past her face and press flat along the ceiling. One hard tungsten bulb directly overhead, the street outside cold and blue. Wide camera at counter height, real density in the steam, film grain, slight vignette, no text.

產生此樣本的請求
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "A late-night noodle counter, six stools and a steel pass, rain on the window behind. A cook in an orange quilted jacket has just lifted the lid off a stock pot. The steam is not dispersing: it has gathered into solid braided ribbons of coral and ultraviolet that rope up past her face and press flat along the ceiling. One hard tungsten bulb directly overhead, the street outside cold and blue. Wide camera at counter height, real density in the steam, film grain, slight vignette, no text."
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "16:9"
}
}
}

將 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-3.1-flash-lite-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 / 3:2 / 2:3 / 3:4 / 4:3 / 4:5 / 5:4 / 9:16 / 16:9 / 21:9
generationConfig.imageConfig.imageSize 否 1K

Lite 僅支援 1K 以及 1:1、3:2、2:3、3:4、4:3、4:5、5:4、9:16、16:9 和 21:9。官方文件沒有公佈參考圖片數量上限,因此網關沒有增加本地上限,超出服務限制時返回服務錯誤。

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

終端機視窗bash
curl "https://modelflare.dev/v1/models/gemini-3.1-flash-lite-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-3.1-flash-lite-image 的原生 Gemini 響應形狀並保留可用的影像部分。

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

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

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

媒體合約 · v1

合約 ID: media.gemini-3-1-flash-lite-image.v1適配器: image.gemini.native.v1@v1指紋: 3eb181032c0d879a99b4c879c0ee28f714c72bf3d9c228ccc50eb61a3778b79e

官方來源: Google

合約參數

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

支援的功能

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

結構化請求範例

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."
      }
    ]
  }
}