Gemini 影像(Nano Banana)
post/v1beta/models/{model}:generateContent
使用 Gemini 生成影像。
驗證
把 OLETOKEN 的 API Key 作為 Bearer Token 放進 Authorization 請求標頭。金鑰在控制台的「API 金鑰」頁建立。
Authorization: Bearer $OLETOKEN_API_KEY請求參數
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| modelpath | string | 模型名稱 |
請求主體
Content-Type:application/json
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| contents | object[] | — | |
| role | string | — | — |
| parts | object[] | — | — |
| text | string | — | — |
| generationConfig | object | — | |
| responseModalities | string[] | — | |
| imageConfig | object | — | — |
| aspectRatio | string | — | — |
| imageSize | string | — | — |
回應
200OK
| 欄位 | 類型 | 必填 | 說明 |
|---|---|---|---|
| candidates | object[] | — | — |
| content | object | — | — |
| role | string | — | — |
| parts | object[] | — | — |
| finishReason | string | — | — |
| safetyRatings | object[] | — | — |
| usageMetadata | object | — | — |
| promptTokenCount | integer | — | — |
| candidatesTokenCount | integer | — | — |
| totalTokenCount | integer | — | — |
請求範例
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"
}
}
}'
