切换主题
Gemini原生格式
Gemini 图片生成
Gemini原生格式
POST /v1beta/models/{model}:generateContent/
Gemini 图片生成
认证
BearerAuth
请求参数
| 名称 | 位置 | 必填 | 类型 | 说明 |
|---|---|---|---|---|
| model | path | 是 | string | 模型名称 |
请求体
必填:否
application/json
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| contents | 是 | array<object> | - |
| contents[].role | 否 | string | - |
| contents[].parts | 否 | array<object> | - |
| generationConfig | 是 | object | - |
| generationConfig.thinkingConfig | 否 | object | - |
| generationConfig.thinkingConfig.includeThoughts | 是 | boolean | 是否返回思考内容 |
| generationConfig.responseModalities | 是 | array<string> | - |
| generationConfig.imageConfig | 是 | object | - |
| generationConfig.imageConfig.aspectRatio | 是 | string | - |
| generationConfig.imageConfig.imageSize | 是 | string | - |
原始 Schema
json
{
"type": "object",
"properties": {
"contents": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
}
},
"x-apifox-orders": [
"text"
]
}
}
},
"x-apifox-orders": [
"role",
"parts"
]
}
},
"generationConfig": {
"type": "object",
"properties": {
"thinkingConfig": {
"type": "object",
"properties": {
"includeThoughts": {
"type": "boolean",
"description": "是否返回思考内容"
}
},
"required": [
"includeThoughts"
],
"x-apifox-orders": [
"includeThoughts"
]
},
"responseModalities": {
"type": "array",
"items": {
"type": "string"
}
},
"imageConfig": {
"type": "object",
"properties": {
"aspectRatio": {
"type": "string"
},
"imageSize": {
"type": "string"
}
},
"required": [
"aspectRatio",
"imageSize"
],
"x-apifox-orders": [
"aspectRatio",
"imageSize"
]
}
},
"required": [
"responseModalities",
"imageConfig"
],
"x-apifox-orders": [
"thinkingConfig",
"responseModalities",
"imageConfig"
]
}
},
"required": [
"contents",
"generationConfig"
],
"x-apifox-orders": [
"contents",
"generationConfig"
]
}响应
200 成功
application/json
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| candidates | 否 | array<object> | - |
| candidates[].content | 否 | object | - |
| candidates[].content.role | 否 | string | - |
| candidates[].content.parts | 否 | array<object> | - |
| candidates[].finishReason | 否 | string | - |
| candidates[].safetyRatings | 否 | array<object> | - |
| usageMetadata | 否 | object | - |
| usageMetadata.promptTokenCount | 否 | integer | - |
| usageMetadata.candidatesTokenCount | 否 | integer | - |
| usageMetadata.totalTokenCount | 否 | integer | - |
原始 Schema
json
{
"type": "object",
"properties": {
"candidates": {
"type": "array",
"items": {
"type": "object",
"properties": {
"content": {
"type": "object",
"properties": {
"role": {
"type": "string"
},
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {},
"x-apifox-orders": []
}
}
},
"x-apifox-orders": [
"role",
"parts"
]
},
"finishReason": {
"type": "string"
},
"safetyRatings": {
"type": "array",
"items": {
"type": "object",
"properties": {},
"x-apifox-orders": []
}
}
},
"x-apifox-orders": [
"content",
"finishReason",
"safetyRatings"
]
}
},
"usageMetadata": {
"type": "object",
"properties": {
"promptTokenCount": {
"type": "integer"
},
"candidatesTokenCount": {
"type": "integer"
},
"totalTokenCount": {
"type": "integer"
}
},
"x-apifox-orders": [
"promptTokenCount",
"candidatesTokenCount",
"totalTokenCount"
]
}
},
"x-apifox-orders": [
"candidates",
"usageMetadata"
]
}