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 | — | — |
响应
200成功
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| 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"
}
}
}'
