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_KEYParameters
| Field | Type | Required | Description |
|---|---|---|---|
| modelpath | string | Model name |
Request body
Content-Type:application/json
| Field | Type | Required | Description |
|---|---|---|---|
| contents | object[] | — | |
| role | string | — | — |
| parts | object[] | — | — |
| text | string | — | — |
| generationConfig | object | — | |
| responseModalities | string[] | — | |
| imageConfig | object | — | — |
| aspectRatio | string | — | — |
| imageSize | string | — | — |
Responses
200OK
| Field | Type | Required | Description |
|---|---|---|---|
| candidates | object[] | — | — |
| content | object | — | — |
| role | string | — | — |
| parts | object[] | — | — |
| finishReason | string | — | — |
| safetyRatings | object[] | — | — |
| usageMetadata | object | — | — |
| promptTokenCount | integer | — | — |
| candidatesTokenCount | integer | — | — |
| totalTokenCount | integer | — | — |
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"
}
}
}'
