Gemini image (Nano Banana)

post/v1beta/models/{model}:generateContent

Image generation with Gemini.

Authentication

Send your OLETOKEN API key as a Bearer token. Keys are created on the API Keys page of the console.

Authorization: Bearer $OLETOKEN_API_KEY

Parameters

FieldTypeRequiredDescription
modelpathstringModel name

Request body

Content-Type:application/json

FieldTypeRequiredDescription
contentsobject[]
rolestring
partsobject[]
textstring
generationConfigobject
responseModalitiesstring[]
imageConfigobject
aspectRatiostring
imageSizestring

Responses

200OK

FieldTypeRequiredDescription
candidatesobject[]
contentobject
rolestring
partsobject[]
finishReasonstring
safetyRatingsobject[]
usageMetadataobject
promptTokenCountinteger
candidatesTokenCountinteger
totalTokenCountinteger

Example request

curl -X POST 'https://api.oletoken.ai/v1beta/models/{model}:generateContent' \
  -H "Authorization: Bearer $OLETOKEN_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
    "contents": [
      {
        "role": "user",
        "parts": [
          {
            "text": "draw a cat"
          }
        ]
      }
    ],
    "generationConfig": {
      "responseModalities": [
        "TEXT",
        "IMAGE"
      ],
      "imageConfig": {
        "aspectRatio": "16:9",
        "imageSize": "4K"
      }
    }
  }'