Imagem do Gemini (Nano Banana)
post/v1beta/models/{model}:generateContent
Geração de imagens com o Gemini.
Autenticação
Envie sua chave de API da OLETOKEN como token Bearer. As chaves são criadas na página Chaves de API do console.
Authorization: Bearer $OLETOKEN_API_KEYParâmetros
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| modelpath | string | Nome do modelo |
Corpo da requisição
Content-Type:application/json
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| contents | object[] | — | |
| role | string | — | — |
| parts | object[] | — | — |
| text | string | — | — |
| generationConfig | object | — | |
| responseModalities | string[] | — | |
| imageConfig | object | — | — |
| aspectRatio | string | — | — |
| imageSize | string | — | — |
Respostas
200OK
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
| candidates | object[] | — | — |
| content | object | — | — |
| role | string | — | — |
| parts | object[] | — | — |
| finishReason | string | — | — |
| safetyRatings | object[] | — | — |
| usageMetadata | object | — | — |
| promptTokenCount | integer | — | — |
| candidatesTokenCount | integer | — | — |
| totalTokenCount | integer | — | — |
Requisição de exemplo
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"
}
}
}'
