Gambar Gemini (Nano Banana)

post/v1beta/models/{model}:generateContent

Pembuatan gambar dengan Gemini.

Autentikasi

Kirim kunci API OLETOKEN sebagai token Bearer. Kunci dibuat di halaman Kunci API pada konsol.

Authorization: Bearer $OLETOKEN_API_KEY

Parameter

FieldTipeWajibKeterangan
modelpathstringNama model

Isi permintaan

Content-Type:application/json

FieldTipeWajibKeterangan
contentsobject[]—
rolestring——
partsobject[]——
textstring——
generationConfigobject—
responseModalitiesstring[]—
imageConfigobject——
aspectRatiostring——
imageSizestring——

Respons

200OK

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

Contoh permintaan

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"
      }
    }
  }'