切换主题
Gemini文本聊天
代理 Gemini API 请求。 路径格式: /v1beta/models/{model_name}:{action}
例如:
/v1beta/models/gemini-2.5-pro:generateContent/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse
Gemini文本聊天
POST /v1beta/models/{model}:generateContent
代理 Gemini API 请求。 路径格式: /v1beta/models/{model_name}:{action}
例如:
/v1beta/models/gemini-2.5-pro:generateContent/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse
认证
BearerAuth
请求参数
| 名称 | 位置 | 必填 | 类型 | 说明 |
|---|---|---|---|---|
| model | path | 是 | string | 模型名称 |
请求体
必填:否
application/json
| 字段 | 必填 | 类型 | 说明 |
|---|---|---|---|
| contents | 否 | array<object> | - |
| contents[].role | 否 | enum: user | model | - |
| contents[].parts | 否 | array<object> | - |
| generationConfig | 否 | object | - |
| generationConfig.temperature | 否 | number | - |
| generationConfig.topP | 否 | number | - |
| generationConfig.topK | 否 | integer | - |
| generationConfig.maxOutputTokens | 否 | integer | - |
| generationConfig.stopSequences | 否 | array<string> | - |
| safetySettings | 否 | array<object> | - |
| safetySettings[].category | 否 | string | - |
| safetySettings[].threshold | 否 | string | - |
| tools | 否 | array<object> | - |
| systemInstruction | 否 | object | - |
| systemInstruction.parts | 否 | array<object> | - |
原始 Schema
json
{
"type": "object",
"properties": {
"contents": {
"type": "array",
"items": {
"type": "object",
"properties": {
"role": {
"type": "string",
"enum": [
"user",
"model"
]
},
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"text": {
"type": "string"
},
"inlineData": {
"type": "object",
"properties": {
"mimeType": {
"type": "string"
},
"data": {
"type": "string"
}
},
"x-apifox-orders": [
"mimeType",
"data"
]
}
},
"x-apifox-orders": [
"text",
"inlineData"
]
}
}
},
"x-apifox-orders": [
"role",
"parts"
]
}
},
"generationConfig": {
"type": "object",
"properties": {
"temperature": {
"type": "number"
},
"topP": {
"type": "number"
},
"topK": {
"type": "integer"
},
"maxOutputTokens": {
"type": "integer"
},
"stopSequences": {
"type": "array",
"items": {
"type": "string"
}
}
},
"x-apifox-orders": [
"temperature",
"topP",
"topK",
"maxOutputTokens",
"stopSequences"
]
},
"safetySettings": {
"type": "array",
"items": {
"type": "object",
"properties": {
"category": {
"type": "string"
},
"threshold": {
"type": "string"
}
},
"x-apifox-orders": [
"category",
"threshold"
]
}
},
"tools": {
"type": "array",
"items": {
"type": "object",
"properties": {},
"x-apifox-orders": []
}
},
"systemInstruction": {
"type": "object",
"properties": {
"parts": {
"type": "array",
"items": {
"type": "object",
"properties": {},
"x-apifox-orders": []
}
}
},
"x-apifox-orders": [
"parts"
]
}
},
"x-apifox-orders": [
"contents",
"generationConfig",
"safetySettings",
"tools",
"systemInstruction"
]
}响应
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"
]
}