DeerAPI Gemini 文本对话文档:通过统一 Base URL 与 API Key 兼容 Gemini 原生接口,支持 generateContent、Thinking、流式响应、Google Search、系统指令等功能。
curl "https://api.deerapi.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <DEERAPI_KEY>" \
-d '{
"contents": [
{
"parts": [
{"text": "Explain how AI works in a few words"}
]
}
]
}'{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{
"text": "<string>",
"thought": true
}
]
},
"finishReason": "STOP",
"tokenCount": 123,
"avgLogprobs": 123,
"groundingMetadata": {},
"urlContextMetadata": {},
"citationMetadata": {},
"finishMessage": "<string>",
"index": 123,
"safetyRatings": [
{
"category": "<string>",
"probability": "<string>"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"cachedContentTokenCount": 123,
"candidatesTokenCount": 123,
"toolUsePromptTokenCount": 123,
"thoughtsTokenCount": 123,
"totalTokenCount": 123,
"promptTokensDetails": [
{
"modality": "<string>",
"tokenCount": 123
}
],
"candidatesTokensDetails": [
{
"modality": "<string>",
"tokenCount": 123
}
]
},
"modelVersion": "<string>",
"responseId": "<string>",
"modelStatus": {
"modelStage": "<string>",
"retirementTime": "<string>",
"message": "<string>"
}
}generateContent、流式响应、Thinking、Google Search 等全部功能。
thinkingLevel 参数控制思考强度:MINIMAL、LOW、MEDIUM、HIGH。推荐用于 gemini-3-pro-preview 等 Gemini 3 系列模型。thinkingBudget 参数控制思考 token 预算:0:禁用思考-1:动态思考(模型自动决定,默认)generateContent 替换为 streamGenerateContent,并添加 ?alt=sse 参数即可接收 Server-Sent Events 格式的流式输出。
详情请参考 Gemini 流式响应文档。
Bearer token authentication. Use your DeerAPI key.
Gemini 模型 ID,不含 models/ 前缀。示例:gemini-2.5-pro、gemini-2.5-flash-all、gemini-3.1-pro-preview。
调用方法。普通响应用 generateContent;流式响应用 streamGenerateContent,并在请求 URL 额外追加 ?alt=sse。
兼容 Gemini generateContent。这个接口最值得先理解的字段是 contents、systemInstruction、generationConfig、tools。不同 Gemini 模型对 thinking、搜索、代码执行、输出模态的支持度并不完全相同。
对话内容数组。单轮场景通常只传 1 个元素;多轮场景则把完整历史按顺序放进去。Gemini 的多模态输入也是通过 parts 组织。
Show child attributes
系统指令。Gemini 把开发者级约束单独放在这里,而不是塞进 contents 第一条。当前通常以文本 parts 为主。
Show child attributes
模型可用的工具列表。常见能力包括函数调用、代码执行,以及 Gemini 3 系列逐步开放的内建搜索/地图类工具。具体可用性要看模型版本。
工具配置,控制函数调用模式、工具选择策略等。
安全设置列表。每个安全类别最多写一次;你传入的值会覆盖该类别的默认拦截阈值。
Show child attributes
缓存内容名称,格式: cachedContents/{cachedContent}。可复用已缓存的内容以降低成本。
请求级日志/存储控制项。只有在你确实需要覆盖项目级默认行为时再传。
生成配置。多数调参都在这里完成,例如输出模态、随机性、最大长度、JSON 输出、thinking。不是所有字段都对所有模型生效。
Show child attributes
curl "https://api.deerapi.com/v1beta/models/gemini-2.5-flash:generateContent" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <DEERAPI_KEY>" \
-d '{
"contents": [
{
"parts": [
{"text": "Explain how AI works in a few words"}
]
}
]
}'{
"candidates": [
{
"content": {
"role": "<string>",
"parts": [
{
"text": "<string>",
"thought": true
}
]
},
"finishReason": "STOP",
"tokenCount": 123,
"avgLogprobs": 123,
"groundingMetadata": {},
"urlContextMetadata": {},
"citationMetadata": {},
"finishMessage": "<string>",
"index": 123,
"safetyRatings": [
{
"category": "<string>",
"probability": "<string>"
}
]
}
],
"usageMetadata": {
"promptTokenCount": 123,
"cachedContentTokenCount": 123,
"candidatesTokenCount": 123,
"toolUsePromptTokenCount": 123,
"thoughtsTokenCount": 123,
"totalTokenCount": 123,
"promptTokensDetails": [
{
"modality": "<string>",
"tokenCount": 123
}
],
"candidatesTokensDetails": [
{
"modality": "<string>",
"tokenCount": 123
}
]
},
"modelVersion": "<string>",
"responseId": "<string>",
"modelStatus": {
"modelStage": "<string>",
"retirementTime": "<string>",
"message": "<string>"
}
}