Gemini 图片(Nano Banana)
POST /v1beta/models/{model}:generateContent
Gemini 图片生成
基本信息
| 项目 | 内容 |
|---|---|
| Base URL | https://www.yunzhuhub.cn |
| 标签 | Gemini格式 |
| Operation ID | geminiRelayV1Beta |
认证
- BearerAuth:使用 Bearer Token 认证。 格式:
Authorization: Bearer sk-xxxxxx
密钥安全
请只使用你自己的 API Key。示例中的 <YOUR_API_KEY> 必须在本地替换,不要把真实密钥提交到代码仓库或发送给他人。
参数
| 名称 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
model | path | string | 是 | 模型名称 |
请求体
Content-Type: application/json
json
{
"type": "object",
"properties": {
"contents": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
}
}
}
}
}
},
"generationConfig": {
"type": "object",
"properties": {
"responseModalities": {
"type": "array",
"items": {
"type": "string"
}
},
"imageConfig": {
"type": "object",
"properties": {
"aspectRatio": {
"type": "string"
},
"imageSize": {
"type": "string"
}
}
}
},
"required": [
"responseModalities"
]
}
},
"required": [
"contents",
"generationConfig"
]
}请求示例
以下示例只用于复制到本地终端,不会从文档站发送请求。
bash
curl --request POST 'https://www.yunzhuhub.cn/v1beta/models/{model}:generateContent' \
--header 'Authorization: Bearer <YOUR_API_KEY>' \
--header 'Content-Type: application/json' \
--data '<REQUEST_JSON>'响应
200 成功
json
{
"title": "GeminiResponse",
"type": "object",
"properties": {
"candidates": {
"type": "array",
"items": {
"type": "object",
"properties": {
"content": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {}
}
}
}
},
"finishReason": {
"type": "string"
},
"safetyRatings": {
"type": "array",
"items": {
"type": "object",
"properties": {}
}
}
}
}
},
"usageMetadata": {
"type": "object",
"properties": {
"promptTokenCount": {
"type": "integer"
},
"candidatesTokenCount": {
"type": "integer"
},
"totalTokenCount": {
"type": "integer"
}
}
}
}
}