Gemini Image
Gemini image models support text-to-image and chat-based image editing.
Method 1: OpenAI-Compatible Format (recommended)
Endpoint
POST $URL/v1/images/generationsSupported Models
| Model | Positioning |
|---|---|
gemini-3-pro-image | High-quality text-to-image |
gemini-3-pro-image-preview | Preview version |
gemini-2.5-flash-image | Lightweight and fast |
gemini-3.1-flash-image | New lightweight version |
Request Example
bash
curl $URL/v1/images/generations \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3-pro-image",
"prompt": "A cat wearing sunglasses walking down a neon-lit street, cyberpunk style",
"n": 1,
"size": "1024x1024"
}'Method 2: Gemini Native Format
If you need the Gemini native image generation endpoint:
POST $URL/v1/models/{model}:generateContentRequest Body Example
json
{
"contents": [
{
"role": "user",
"parts": [
{ "text": "Generate an image of a cat wearing sunglasses in a cyberpunk city." }
]
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}cURL Example
bash
curl $URL/v1/models/gemini-3-pro-image:generateContent \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [{"text": "Generate an image of a cat wearing sunglasses."}]
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"]
}
}'Notes
- Gemini Image supports multi-round chat-based image editing, suitable for scenarios requiring repeated refinement.
- We recommend using the OpenAI-compatible format first to reduce migration cost.
