Create / edit images Generate or edit reference images using the native Gemini API.
POST /v1beta/models/{model}:generateContentTry it Generate images from a prompt, or include reference images in the same request to edit them.
Authorization Bearer <token>
TypeScript Definitions
Use the request body type in TypeScript.
Copy
cURL
JavaScript
Go
Python
Java
C#
Rustcurl -X POST "https://example.com/v1beta/models/MODEL_ID:generateContent" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Create a photo of an orange ceramic vase on a windowsill, with soft window light and a simple background."
}
]
}
],
"generationConfig": {
"responseModalities": [
"IMAGE"
],
"imageConfig": {
"aspectRatio": "1:1"
}
}
}' 200 400 401 403
{
"candidates": [
{
"content": {
"role": "model",
"parts": [
{
"inlineData": {
"mimeType": "image/png",
"data": "BASE64_BYTES"
},
"thoughtSignature": "THOUGHT_SIGNATURE"
}
]
},
"finishReason": "STOP"
}
],
"usageMetadata": {
"promptTokenCount": 23,
"candidatesTokenCount": 1206,
"totalTokenCount": 1925,
"trafficType": "ON_DEMAND",
"promptTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 23
}
],
"candidatesTokensDetails": [
{
"modality": "TEXT",
"tokenCount": 86
},
{
"modality": "IMAGE",
"tokenCount": 1120
}
],
"thoughtsTokenCount": 696
},
"modelVersion": "MODEL_ID",
"createTime": "2026-11-06T18:28:55.590821Z",
"responseId": "RESPONSE_ID"
}
Google Gemini image generation and editing guide Image requests, responses and multi-turn editing.