圖片
gemini-3.1-flash-lite-image API
透過 Modelflare 使用本頁顯示的確切型號 ID 呼叫 gemini-3.1-flash-lite-image。
使用準確的型號 ID gemini-3.1-flash-lite-image。模型欄位必須與此頁面完全相符。

參數: 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" } }}身份驗證與端點
Section titled “身份驗證與端點”將 Modelflare API 金鑰與 https://modelflare.dev 結合使用。網關入口點是POST /v1/models/{model}:generateContent。
Authorization: Bearer YOUR_MODELFLARE_API_KEYcurl "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 |
回應與輸入限制
Section titled “回應與輸入限制”Lite 僅支援 1K 以及 1:1、3:2、2:3、3:4、4:3、4:5、5:4、9:16、16:9 和 21:9。官方文件沒有公佈參考圖片數量上限,因此網關沒有增加本地上限,超出服務限制時返回服務錯誤。
影像編輯範例
Section titled “影像編輯範例”將編輯指令和參考影像放在同一個contents[].parts[]中。 inline_data.data為Base64影像內容;請勿將 Gemini 影像模型傳送至 OpenAI 影像或 Responses 端點。
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 響應形狀並保留可用的影像部分。
錯誤與失敗的任務
Section titled “錯誤與失敗的任務”來自本機 Gemini 請求的欄位錯誤、大小/比率限制和安全拒絕仍然是與 Gemini 相容的錯誤回應。網關不會將它們重寫為 OpenAI Images 回應。
此頁面涵蓋 Modelflare 模型產生和編輯呼叫。搜尋或地圖豐富、語音管理和元素庫管理是此公共模型呼叫表面之外的資源 API,並且不是必需的請求欄位。
此模型使用基於令牌的計費。請參閱 型號定價頁面 ,以了解當前客戶價格、參考標價和完整規格。
媒體合約 · v1
官方來源: Google
合約參數
| 意圖字段 | 控制項 | 選項 |
|---|---|---|
size | select | 1K |
ratio | select | 1:1 / 3:2 / 2:3 / 3:4 / 4:3 / 4:5 / 5:4 / 9:16 / 16:9 / 21:9 |
支援的功能
allowed_values·size· 1Kallowed_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."
}
]
}
}