Gemini native
Native Gemini API
POST/v1beta/models/{model}:generateContent
Compatible with Google's native generateContent protocol, with Bearer auth. Both text and image generation use this endpoint — drop-in for existing Gemini code.
Request body (generateContent)
| Field | Type | Required | Description |
|---|---|---|---|
| contents | object[] | Required | Conversation contents, each {role, parts:[{text|inline_data}]} |
| systemInstruction | object | Optional | System instruction |
| generationConfig | object | Optional | Generation params: temperature / maxOutputTokens / topP / topK … |
| safetySettings | object[] | Optional | Safety filter settings |
Text example
bash
curl "https://your-domain/v1beta/models/gemini-2.5-pro:generateContent" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{ "role": "user", "parts": [{ "text": "Hello, Gemini" }] }],
"generationConfig": { "temperature": 0.7 }
}'Image generation
Generate images with the same generateContent endpoint: add responseModalities and imageConfig (aspectRatio, imageSize) to generationConfig. For image-to-image, put the input image as inline_data (mime_type + base64) inside contents[].parts.
| Field | Type | Required | Description |
|---|---|---|---|
| generationConfig.responseModalities | string[] | Required | Response modalities. Pass ["IMAGE"] for image generation; use ["TEXT","IMAGE"] to also return text |
| generationConfig.imageConfig | object | Required | Image generation config (aspectRatio + imageSize) |
| imageConfig.aspectRatio | string | Required | Aspect ratio: 1:1 / 3:2 / 2:3 / 4:3 / 3:4 / 5:4 / 4:5 / 16:9 / 9:16 / 21:9 |
| imageConfig.imageSize | string | Required | Image quality tier: 1K / 2K / 4K |
| parts[].inline_data | object | Optional | Image-to-image input: { mime_type, data(base64) } inside contents[].parts |
bash
curl "https://your-domain/v1beta/models/gemini-3.1-flash-image-preview:generateContent" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{ "role": "user", "parts": [{ "text": "a neon fox, cinematic" }] }],
"generationConfig": {
"responseModalities": ["IMAGE"],
"imageConfig": { "aspectRatio": "16:9", "imageSize": "2K" }
}
}'Supported models
Image-generation model below; text generation accepts standard Gemini models (e.g. gemini-2.5-pro).
gemini-3.1-flash-image-previewgemini-2.5-flash-image