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

Parameter: size=2Kratio=16:9
Prompt: 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" } }}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-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"}} }'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 | 1K / 2K / 4K |
Batas respons dan masukan
Section titled “Batas respons dan masukan”Gambar Flash Gemini 2.5 mendukung 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-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"}} }'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-2.5-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 per panggilan. 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 | 1K / 2K / 4K |
ratio | select | 1:1 / 4:3 / 3:4 / 16:9 / 9:16 |
Kemampuan yang didukung
allowed_values·size· 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": "1K"
}Permintaan penyedia
{
"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
Maksud
{
"prompt": "A red paper kite over a quiet harbour at dusk.",
"ratio": "1:1",
"size": "1K"
}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": "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."
}
]
}
}