Imagen de Gemini (Nano Banana)
post/v1beta/models/{model}:generateContent
Generación de imágenes con Gemini.
Autenticación
Envía tu clave de API de OLETOKEN como token Bearer. Las claves se crean en la página Claves de API de la consola.
Authorization: Bearer $OLETOKEN_API_KEYParámetros
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| modelpath | string | Nombre del modelo |
Cuerpo de la solicitud
Content-Type:application/json
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| contents | object[] | — | |
| role | string | — | — |
| parts | object[] | — | — |
| text | string | — | — |
| generationConfig | object | — | |
| responseModalities | string[] | — | |
| imageConfig | object | — | — |
| aspectRatio | string | — | — |
| imageSize | string | — | — |
Respuestas
200OK
| Campo | Tipo | Obligatorio | Descripción |
|---|---|---|---|
| candidates | object[] | — | — |
| content | object | — | — |
| role | string | — | — |
| parts | object[] | — | — |
| finishReason | string | — | — |
| safetyRatings | object[] | — | — |
| usageMetadata | object | — | — |
| promptTokenCount | integer | — | — |
| candidatesTokenCount | integer | — | — |
| totalTokenCount | integer | — | — |
Solicitud de ejemplo
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"
}
}
}'
