รูปภาพ Gemini (Nano Banana)

post/v1beta/models/{model}:generateContent

การสร้างรูปภาพด้วย Gemini

การยืนยันตัวตน

ส่งคีย์ API ของ OLETOKEN เป็น Bearer token สร้างคีย์ได้ที่หน้า API Keys ในคอนโซล

Authorization: Bearer $OLETOKEN_API_KEY

พารามิเตอร์

ฟิลด์ประเภทจำเป็นคำอธิบาย
modelpathstringชื่อโมเดล

เนื้อหาคำขอ

Content-Type:application/json

ฟิลด์ประเภทจำเป็นคำอธิบาย
contentsobject[]—
rolestring——
partsobject[]——
textstring——
generationConfigobject—
responseModalitiesstring[]—
imageConfigobject——
aspectRatiostring——
imageSizestring——

การตอบกลับ

200สำเร็จ

ฟิลด์ประเภทจำเป็นคำอธิบาย
candidatesobject[]——
contentobject——
rolestring——
partsobject[]——
finishReasonstring——
safetyRatingsobject[]——
usageMetadataobject——
promptTokenCountinteger——
candidatesTokenCountinteger——
totalTokenCountinteger——

ตัวอย่างคำขอ

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