Skip to navigation

Gemini Image Models

View as Markdown

Gemini image models use the image generation endpoint with a Generate Content-compatible request body. Use gemini-3.1-flash-image for general image generation, gemini-3-pro-image for professional visual assets, and gemini-2.5-flash-image for existing Nano Banana workflows.

curl https://api.getopenmodels.com/v1/images \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OM_API_KEY" \
-d '{
"model": "gemini-3.1-flash-image",
"route": { "provider": "<provider-for-this-model>" },
"route_mode": "balanced",
"contents": [
{
"role": "user",
"parts": [
{
"text": "Generate an image of a Chinese Li Hua cat in a modern studio product-photo style."
}
]
}
],
"generationConfig": {
"responseModalities": ["TEXT", "IMAGE"],
"responseFormat": {
"image": {
"aspectRatio": "16:9",
"imageSize": "2K"
}
}
}
}'

For Gemini image models, set image generation options in generationConfig.

FieldTypeNotes
modelstringSupported values: gemini-3-pro-image, gemini-3.1-flash-image, gemini-2.5-flash-image.
contentsarrayRequired Generate Content input. Use user messages with parts for text prompts and optional image inputs.
contents[].parts[].textstringText prompt that describes the image to generate or edit.
contents[].parts[].inline_dataobjectOptional image input for reference-image or image-editing workflows. Set mime_type and base64 data.
generationConfig.responseModalitiesarrayOutput modalities. Use ["TEXT", "IMAGE"] when you want both text and image parts, or ["IMAGE"] for image-only output.
generationConfig.responseFormat.image.aspectRatiostringOutput aspect ratio. Common values include 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9. gemini-3.1-flash-image also supports wider ratios such as 1:4, 4:1, 1:8, and 8:1.
generationConfig.responseFormat.image.imageSizestringOutput size for gemini-3-pro-image and gemini-3.1-flash-image. Valid values include 1K, 2K, and 4K; gemini-3.1-flash-image also supports 512. Omit this field for gemini-2.5-flash-image.
tools[].google_searchobjectOptional grounding tool for Gemini 3 image models when the prompt needs current or factual web information.

Gemini image models also support OpenAI-compatible multimodal chat messages. Use this shape when your client sends image inputs through messages[].content[]:

curl https://api.getopenmodels.com/v1/chat/completions \
-H "Authorization: Bearer $OM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-image",
"route": { "provider": "<provider-for-this-model>" },
"route_mode": "balanced",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What is in this image?"
},
{
"type": "image_url",
"image_url": {
"url": "https://live.staticflickr.com/3851/14825276609_098cac593d_b.jpg"
}
}
]
}
]
}'