Gambar
gemini-3.1-flash-imageAPI
Panggil gemini-3.1-flash-image melalui Modelflare dengan ID model persis seperti yang ditampilkan di halaman ini.
Gunakan ID model yang tepat gemini-3.1-flash-image. Bidang model harus sama persis dengan halaman ini.

Parameter: size=2Kratio=16:9
Prompt: The cold room of a flower shop, steel shelves and buckets of cut stems. A figure in an acid-green vinyl coat has just pulled one bucket toward the door. Along that whole shelf the flowers have begun turning to blown glass, petal by petal, the transformation running outward from the bucket like frost: stems still green at the base, heads already clear and ringing, throwing hard coloured caustics across the steel. One hard pink light through the open cooler door, cold blue shade behind. Wide low camera, macro-sharp on the glass edges, real weight, film grain, no text.
{ "contents": [ { "role": "user", "parts": [ { "text": "The cold room of a flower shop, steel shelves and buckets of cut stems. A figure in an acid-green vinyl coat has just pulled one bucket toward the door. Along that whole shelf the flowers have begun turning to blown glass, petal by petal, the transformation running outward from the bucket like frost: stems still green at the base, heads already clear and ringing, throwing hard coloured caustics across the steel. One hard pink light through the open cooler door, cold blue shade behind. Wide low camera, macro-sharp on the glass edges, real weight, film grain, no text." } ] } ], "generationConfig": { "responseModalities": [ "IMAGE" ], "imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" } }}Otentikasi dan titik akhir
Section titled “Otentikasi dan titik akhir”Gunakan kunci API Modelflare dengan https://modelflare.dev. Titik masuk gateway adalah POST /v1/models/{model}:generateContent.
Authorization: Bearer YOUR_MODELFLARE_API_KEYMenghasilkan gambar
Section titled “Menghasilkan gambar”curl "https://modelflare.dev/v1/models/gemini-3.1-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"}} }'Minta catatan
Section titled “Minta catatan”Model gambar Gemini menggunakan contents dan generationConfig asli; editan mengirim instruksi teks dan inline_data di parts[] yang sama.
Parameter permintaan
Section titled “Parameter permintaan”Model gambar Gemini menggunakan Gemini asli generateContent. Letakkan teks dan gambar referensi di contents[].parts[] yang sama; gambar menggunakan inline_data. Jangan kirim model ini ke /v1/images/generations, /v1/images/edits, atau OpenAI /v1/responses. Enum imageSize khusus untuk model dan ditunjukkan di bawah.
| Bidang | Wajib diisi | Catatan |
|---|---|---|
contents[].parts[].text |
Ya | Perintah teks atau instruksi edit |
contents[].parts[].inline_data |
Tidak | Data gambar Base64 dan tipe MIME |
contents[].parts[].inline_data.mime_type |
Tidak | image/jpeg / image/png / image/webp |
contents[].parts[].inline_data.data |
Tidak | Konten gambar referensi berkode Base64 |
generationConfig.responseModalities |
Ya | ["IMAGE"] atau ["TEXT", "IMAGE"] |
generationConfig.imageConfig.aspectRatio |
Tidak | 1:1 / 4:3 / 3:4 / 16:9 / 9:16 |
generationConfig.imageConfig.imageSize |
Tidak | 512 / 1K / 2K / 4K |
Batas respons dan masukan
Section titled “Batas respons dan masukan”Gambar Flash mendukung 512, 1K, 2K, dan 4K dengan 1:1, 4:3, 3:4, 16:9, dan 9:16. Dokumentasi resmi tidak menerbitkan batasan jumlah gambar referensi, sehingga gateway tidak menambahkan batasan lokal.
Contoh pengeditan gambar
Section titled “Contoh pengeditan gambar”Letakkan instruksi edit dan gambar referensi di contents[].parts[] yang sama. inline_data.data adalah konten gambar Base64; jangan mengirim model gambar Gemini ke Gambar OpenAI atau titik akhir Responses.
curl "https://modelflare.dev/v1/models/gemini-3.1-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"}} }'Bentuk respons
Section titled “Bentuk respons”Baca candidates[].content.parts[]; jangan berasumsi setiap bagian adalah gambar karena responsnya mungkin berisi teks dan bagian gambar secara bersamaan.
| Bidang | Catatan |
|---|---|
candidates[].content.parts[].inline_data |
Menghasilkan tipe MIME gambar dan data Base64 |
candidates[].content.parts[].text |
Keterangan teks dikembalikan ketika TEXT diminta |
candidates[].finishReason |
Alasan penyelesaian atau keamanan |
usageMetadata |
Penggunaan token input/output saat dikembalikan oleh layanan |
Modelflare mempertahankan bentuk respons Gemini asli untuk gemini-3.1-flash-image dan mempertahankan bagian gambar yang dapat digunakan.
Kesalahan dan tugas yang gagal
Section titled “Kesalahan dan tugas yang gagal”Kesalahan bidang, batas ukuran/rasio, dan penolakan keamanan dari permintaan Gemini asli tetap menjadi respons kesalahan yang kompatibel dengan Gemini. Gateway tidak menulis ulang gambar tersebut sebagai respons Gambar OpenAI.
Cakupan yang didukung
Section titled “Cakupan yang didukung”Halaman ini mencakup pembuatan model Modelflare dan panggilan pengeditan. Pengayaan penelusuran atau peta, pengelolaan suara, dan pengelolaan pustaka elemen merupakan API sumber daya di luar permukaan panggilan model publik ini dan bukan merupakan bidang permintaan yang wajib diisi.
Pricing and billing
Section titled “Pricing and billing”Model ini menggunakan penagihan berbasis token. Lihat halaman harga model untuk harga pelanggan saat ini, harga daftar referensi, dan spesifikasi lengkap.
Kontrak media · v1
Sumber resmi: Google
Parameter kontrak
| Bidang maksud | Kontrol | Pilihan |
|---|---|---|
size | select | 512 / 1K / 2K / 4K |
ratio | select | 1:1 / 4:3 / 3:4 / 16:9 / 9:16 |
Kemampuan yang didukung
allowed_values·size· 512, 1K, 2K, 4Kallowed_values·ratio· 1:1, 4:3, 3:4, 16:9, 9:16
Contoh permintaan terstruktur
text
Maksud
{
"prompt": "A red paper kite over a quiet harbour at dusk.",
"ratio": "1:1",
"size": "512"
}Permintaan penyedia
{
"contents": [
{
"parts": [
{
"text": "A red paper kite over a quiet harbour at dusk."
}
],
"role": "user"
}
],
"generationConfig": {
"imageConfig": {
"aspectRatio": "1:1",
"imageSize": "512"
},
"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
Maksud
{
"prompt": "A red paper kite over a quiet harbour at dusk.",
"ratio": "1:1",
"size": "512"
}Permintaan penyedia
{
"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": "512"
},
"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."
}
]
}
}