Generate Gemini content

Gemini image generation

POST /v1beta/models/{model}:generateContent

Service root: https://getrouter.ai

Protocol: Gemini-compatible

Authentication: x-goog-api-key: YOUR_API_KEY

Parameters

ParameterLocationTypeRequiredDescription
modelpathstringYesModel name

Request body

The request body is optional. Media type: application/json

Request fields

FieldTypeRequiredDescription
contentsarray<object>Yes
generationConfigobjectYes

Example request

curl --request POST \
  --url https://getrouter.ai/v1beta/models/MODEL_ID:generateContent \
  --header "x-goog-api-key: YOUR_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
  "contents": [
    {}
  ],
  "generationConfig": {
    "responseModalities": [
      "string"
    ]
  }
}'

Responses

StatusDescription
200Successful

Success response fields

FieldTypeRequiredDescription
candidatesarray<object>No
usageMetadataobjectNo

Example response

{
  "candidates": [
    {
      "content": {
        "role": "user",
        "parts": [
          {}
        ]
      },
      "finishReason": "string",
      "safetyRatings": [
        {}
      ]
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 1,
    "candidatesTokenCount": 1,
    "totalTokenCount": 1
  }
}

For complete workflows and examples, read the Gemini API API Guide.


This page is generated from the public Relay OpenAPI specification. Browse the complete specification in the API Explorer.