DocumentationAccess MethodsGemini Images

Gemini Images

Image generation and understanding via the Gemini generateContent protocol.

Endpoint

GeneratePOST /v1beta/models/{'{model}'}:generateContent

Authentication

HeaderAuthorization: Bearer YOUR_API_KEY

Replace in the URL with a configured image model name in Router.

Text-to-image curl example

curl
curl https://your-router-domain.com/v1beta/models/YOUR_IMAGE_MODEL:generateContent \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[{"text":"draw a cat sitting on a sofa"}]}]}'

Image-to-image curl example (with input image)

curl
curl https://your-router-domain.com/v1beta/models/YOUR_IMAGE_MODEL:generateContent \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contents":[{"role":"user","parts":[
        {"text":"add a red hat"},
        {"inlineData":{"mimeType":"image/png","data":"BASE64_IMAGE"}}
      ]}]}'
Response format

Generated images are returned in candidates[].content.parts[].inlineData, containing mimeType and base64 data. A single response may contain both text and image parts — parse each part by type.

OpenAI ImagesImage / Video Tasks