Gemini 影像(Nano Banana)

post/v1beta/models/{model}:generateContent

使用 Gemini 生成影像。

驗證

把 OLETOKEN 的 API Key 作為 Bearer Token 放進 Authorization 請求標頭。金鑰在控制台的「API 金鑰」頁建立。

Authorization: Bearer $OLETOKEN_API_KEY

請求參數

欄位類型必填說明
modelpathstring模型名稱

請求主體

Content-Type:application/json

欄位類型必填說明
contentsobject[]
rolestring
partsobject[]
textstring
generationConfigobject
responseModalitiesstring[]
imageConfigobject
aspectRatiostring
imageSizestring

回應

200OK

欄位類型必填說明
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"
      }
    }
  }'