Gemini文本聊天
代理 Gemini API 请求。 路径格式: `/v1beta/models/{model_name}:{action}` 例如: - `/v1beta/models/gemini-2.5-pro:generateContent` - `/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse`
POST
https://api.xiexus.cn/v1beta/models/{model}:generateContent
请求体:可选
接口信息
方法
POST路径
/v1beta/models/{model}:generateContent完整地址
https://api.xiexus.cn/v1beta/models/{model}:generateContent请求体
可选
标签
聊天(Chat)/原生Gemini格式
响应码
200
静态文件
当前接口页内已嵌入 OpenAPI JSON;如果需要查看总文件,可直接打开固定静态文件
relay.json。当前 JSON
../../../openapi/generated/ai-model/聊天(Chat)/原生Gemini格式/post-v1beta-models-model-generatecontent-geminirelayv1beta-383826489.json总文件
../../../openapi/relay.jsonOpenAPI JSON
已将服务地址固定为
https://api.xiexus.cn,其余结构保持和源文档一致。{
"openapi": "3.1.0",
"info": {
"title": "Gemini文本聊天",
"version": "1.0.0",
"description": "代理 Gemini API 请求。\n路径格式: `/v1beta/models/{model_name}:{action}`\n\n例如:\n- `/v1beta/models/gemini-2.5-pro:generateContent`\n- `/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse`\n"
},
"tags": [
{
"name": "聊天(Chat)/原生Gemini格式"
}
],
"components": {
"securitySchemes": {
"BearerAuth": {
"type": "http",
"scheme": "bearer",
"description": "使用 Bearer Token 认证。\n格式: `Authorization: Bearer sk-xxxxxx`\n"
}
}
},
"paths": {
"/v1beta/models/{model}:generateContent": {
"post": {
"tags": [
"聊天(Chat)/原生Gemini格式"
],
"summary": "Gemini文本聊天",
"description": "代理 Gemini API 请求。\n路径格式: `/v1beta/models/{model_name}:{action}`\n\n例如:\n- `/v1beta/models/gemini-2.5-pro:generateContent`\n- `/v1beta/models/gemini-2.5-pro:streamGenerateContent?alt=sse`\n",
"operationId": "geminirelayv1beta",
"parameters": [
{
"name": "model",
"in": "path",
"required": true,
"description": "模型名称",
"schema": {
"type": "string"
}
}
],
"requestBody": {
"required": false,
"content": {
"application/json": {
"schema": {
"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"
]
}
}
}
},
"security": [
{
"BearerAuth": []
}
],
"responses": {
"200": {
"description": "成功",
"content": {
"application/json": {
"schema": {
"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"
]
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://api.xiexus.cn",
"description": "固定生产地址"
}
]
}