Generate or edit an image with the native Gemini protocol

POST
/v1/router/google/v1beta/models/{model}:generateContent

Alias: /google/v1beta/models/{model}:generateContent. A grouped SDK base URL is /google/{group}; API versions v1 and v1beta are accepted. Only registered image models with google.generateContent supply are eligible. Send complete model contents, including thoughtSignature, when editing across turns. Responses retain candidates, parts, inlineData, usageMetadata and safety feedback. This non-streaming native endpoint does not upload images to platform Media.

Authorization

x-goog-api-key<token>

Platform API key, verified by Identity.

In: header

Path Parameters

model*string

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

curl -X POST "https://example.com/v1/router/google/v1beta/models/string:generateContent" \  -H "Content-Type: application/json" \  -d '{    "contents": [      {        "role": "user",        "parts": [          {            "text": "Draw an orange cup on a cream background."          }        ]      }    ],    "generationConfig": {      "responseModalities": [        "IMAGE"      ],      "imageConfig": {        "aspectRatio": "1:1",        "imageSize": "1K"      }    }  }'
{}