DeerAPI-API文档
  1. Gemini
DeerAPI-API文档
  • 快速开始
    • 快速开始
    • 入门必看
    • DeerAPI 公告
  • API 参考
    • 报错状态码说明
    • OpenAI格式
      • Chat Completions
      • Responses
      • gpt-4o-image生图
      • 图像
      • 图像编辑(gpt-image-1)
      • Embeddings
      • 获取模型列表
      • response id获取结果
      • Hunyuan3D
    • Anthropic 格式
      • Anthropic Claude
    • Gemini
      • 调用 gemini-3-pro-image 指南
      • Gemini生图
        POST
      • Gemini 文本对话
        POST
    • Midjourney 图像生成
      • 快速教学-完整流程一遍过
      • 任务查询
        • 分页查询
        • 指定ID获取任务
      • 提交Imagine任务
      • 提交视频任务
      • 提交编辑任务
      • 提交Action任务
      • 提交Blend任务
      • 提交Describe任务
      • 提交Modal
    • 图像生成
      • Replicate(image)
        • 创建任务-通用
        • 查询任务
      • 豆包生图
        • seededit-image-generation
        • seededit-Image Editing
      • Flux(images)
        • 创建任务-replicate格式
        • 生成图片
        • 查询任务
        • 生成图片(replicate格式)
    • 音乐生成
      • Suno
        • 设置 suno 版本
        • Suno API 场景应用指南
        • 生成歌词
        • 生成音乐
        • 上传音乐
        • 歌曲拼接
        • 全轨声曲分离
        • 单轨声曲分离
        • 新建 Persona
        • 拓展 style tags
        • 查询单个任务
        • 生成 mp4 mv 视频
        • 获取 wav 格式文件
        • Timing:歌词、音频时间线
        • 批量查询任务
        • 获取 midi
    • 视频生成
      • sora-2
        • 官方格式
          • 创建视频
          • 混编视频
          • 检索视频
          • 下载视频
        • 逆向
          • 逆向异步格式
            • sora逆向异步
            • sora逆向查回
          • sora-2视频逆向格式
      • veo3
        • 逆向异步格式
          • veo3逆向异步
          • veo3逆向查回
        • veo3-chat格式
      • kling (video)
        • Callback协议
        • 多模态视频编辑
          • 初始化待编辑视频
          • 增加视频选区
          • 删减视频选区
          • 清除视频选区
          • 预览已选区视频
          • 创建任务
        • 文生视频
        • 图生视频
        • 多图参考生视频
        • 视频延长
        • 语音合成
        • Kling 数字人创建任务
        • 【对口型】人脸识别
        • 【对口型】创建任务
        • 视频特效
        • 文生音效
        • 视频生音效
        • 图像生成
        • 多图参考生图
        • 扩图
        • 图像识别
        • 虚拟试穿
        • 查询任务(单个)
      • runway(video)
        • 官方格式
          • 图像生成视频
          • 视频生视频
          • 提升清晰度
          • 文生图
          • 控制角色
          • 获取任务详细信息
        • 逆向格式
          • generate(文本)
          • generate(参考图片)
          • video2video 视频转视频 风格重绘
          • Act-one 表情迁移
          • feed-获取任务
      • MiniMax 海螺(video)
        • 官方文档
        • 视频生成
        • 查询任务
        • 文件下载
      • seedace测试中
        • 视频-测试中
          • seedance
          • seedance-video
          • seedance-video get
      • luma (video)
        • 官方API格式
          • 生成视频
          • 单个查询任务
    • 音频
      • 文本转音频
      • 音频转文本
      • 创建翻译
  • 代码示例
    • 代码示例
  • 集成指南
    • 应用集成指南
      • DeerAPI 本站调用
      • OpenManus
      • Chatbox
      • CherryStudio
      • COZE
      • Cursor
      • Lobe-Chat
      • NEXT CHAT (ChatGPT Next Web)
      • AnythingLLM
      • cline
      • gptme
      • LangChain
      • ChatHub
      • ChatAll
      • Dify
      • Zotero
      • librechat
      • avante.nvim
      • IntelliJ Translation Plugin
      • FastGPT
      • OpenAI Translator
      • Open WebUI
      • obsidian的text generator插件
      • STranslate
      • 沉浸式翻译
      • Pot 翻译
      • 欧陆翻译
      • GPT 学术优化(gpt_academic)
      • utools-ChatGPT 好友
      • 懒人客服
    • 最佳实践
      • Claude code 接入说明
      • Deerapi 账户余额查询API 使用说明
      • 使用 DeerAPI 和 OpenAI 官方 API 的重试逻辑说明文档
      • Midjorney调用最佳实践
      • Runway调用最佳实践
  • 定价计费
    • 关于价格
    • 关于分组
  • 帮助中心
    • 帮助中心
    • 接口稳定性
    • 常见误区
    • 使用困惑
    • 隐私政策
    • 服务条款
  1. Gemini

Gemini 文本对话

POST
https://api.deerapi.com/v1beta/models/{model}:{function}

Gemini API 文档#

⚠️ 最新动态: gemini-3-pro-preview 现已支持!

简介#

DeerAPI 支持 Gemini 原生格式调用。您可以直接参考 Gemini 官方文档 进行开发。

快速开始#

只需简单替换官方 SDK 或请求中的 Base URL 和 API Key 即可使用:
Base URL: https://api.deerapi.com (替换 generativelanguage.googleapis.com)
API Key: 将 $GEMINI_API_KEY 替换为您的 $DEERAPI_KEY

基础示例:文本生成#

curl "https://api.deerapi.com/v1beta/models/gemini-3-pro-preview:generateContent" \
  -H "x-goog-api-key: $DEERAPI_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "How does AI work?"
          }
        ]
      }
    ]
  }'

常见问题 (FAQ)#

1. 如何控制思考 (Thinking)?#

Gemini 模型支持“思考”过程以提升推理能力。控制方式取决于模型版本。
详情请参考官方文档: Gemini 思考指南

Gemini 3 系列 (如 gemini-3-pro-preview)#

使用 thinkingLevel 参数控制思考强度 ("LOW" 或 "HIGH")。
curl "https://api.deerapi.com/v1beta/models/gemini-3-pro-preview:generateContent" \
  -H "x-goog-api-key: $DEERAPI_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{ "parts": [{ "text": "Explain quantum physics simply." }] }],
    "generationConfig": {
      "thinkingConfig": {
        "thinkingLevel": "LOW"
      }
    }
  }'

Gemini 2.5 系列 (如 gemini-2.5-pro)#

使用 thinkingBudget 参数控制思考的 Token 预算。
0: 禁用思考。
-1: 动态思考 (模型自动决定,默认)。
> 0: 设置具体的 Token 数量上限 (例如 1024)。
curl "https://api.deerapi.com/v1beta/models/gemini-2.5-pro:generateContent" \
  -H "x-goog-api-key: $DEERAPI_KEY" \
  -H 'Content-Type: application/json' \
  -X POST \
  -d '{
    "contents": [{ "parts": [{ "text": "Solve this logic puzzle." }] }],
    "generationConfig": {
      "thinkingConfig": {
        "thinkingBudget": 1024
      }
    }
  }'

2. 如何使用流式响应 (Streaming)?#

流式响应允许您在模型生成内容时逐步接收结果,从而降低感知的延迟。
详情请参考官方文档: Gemini 文本生成 - 流式响应
注意: URL 需指向 streamGenerateContent 且建议添加 ?alt=sse 以使用 Server-Sent Events 格式。
curl "https://api.deerapi.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $DEERAPI_KEY" \
  -H 'Content-Type: application/json' \
  --no-buffer \
  -d '{
    "contents": [
      {
        "parts": [
          {
            "text": "Explain how AI works"
          }
        ]
      }
    ]
  }'

请求参数

Path 参数

Header 参数

Body 参数application/json

示例

返回响应

🟢200成功
application/json
Body

请求示例请求示例
Shell
JavaScript
Java
Swift
cURL
curl --location --request POST 'https://api.deerapi.com/v1beta/models/gemini-3-pro-preview:generateContent' \
--header 'Authorization: ' \
--header 'Content-Type: application/json' \
--data-raw '{
  "contents": [
    {
      "parts": [
        {
          "text": "How does AI work?"
        }
      ]
    }
  ]
}'
响应示例响应示例
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "text": "Here's a detailed prompt designed to achieve that specific vision, emphasizing the requested details and style:\n\n```\n**Character:** A beautiful, serene Asian woman with delicate features, a soft, gentle expression, and dark hair elegantly styled, possibly with a few wisps framing her face. She has subtle makeup, highlighting her natural beauty.\n\n**Pose and Attire:** She is leaning gracefully and comfortably against an ornate, dark wooden railing of a traditional Chinese building. Her right hand is delicately poised, gently touching a large, vibrant kite. She wears a stunning, richly textured **deep blue silk cheongsam (qipao)**. The cheongsam is adorned with intricate and vibrant **pink and crimson red floral motifs**, likely peonies, cherry blossoms, or other traditional Chinese flowers, showcasing exquisite embroidery and subtle brocade patterns that catch the light. The fabric should show a subtle sheen and deep textural detail.\n\n**Headdress:** An elaborate and colorful **headdress crafted from fresh, vivid flowers**, including lush, velvety roses (in shades of pink and red), delicate lavender lilacs, and perhaps smaller complementary blossoms, artfully arranged in her hair. Each petal and leaf should be distinctly rendered.\n\n**Prop (Kite):** A large, traditional Chinese kite with a prominent, rich **blue background**. It is beautifully decorated with playful and detailed **pink koi fish motifs** swimming across its surface. A pair of strikingly large, expressive eyes are painted on the kite, adding a touch of whimsy. The kite's material should appear slightly translucent and textured, showing the delicate framework beneath.\n\n**Background:** The interior of an ancient, richly textured traditional Chinese wooden building. The backdrop features intricately carved wooden beams, decorative lattice windows or screens, and aged wooden wall panels. The atmosphere is **dimly lit and cozy**, with warm, soft light filtering in from unseen windows or lanterns, creating subtle highlights and deep, inviting shadows. Focus on the authentic grain of the old wood and the fine details of the carvings.\n\n**Lighting and Style:** **Hyperrealistic portrait photography, extremely high detail.** The lighting should be soft, directional, and atmospheric, emphasizing the textures. There should be a shallow depth of field, with the woman and the kite in sharp, exquisite focus, while the background gently blurs into a warm, cozy ambiance. Emphasize the tactile qualities: the smooth sheen of the cheongsam, the soft, velvety petals of the roses, the delicate, papery texture of the kite, and the aged, rough grain of the wooden structures. Cinematic lighting.\n```"
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0,
      "safetyRatings": null
    }
  ],
  "promptFeedback": {
    "safetyRatings": null
  },
  "usageMetadata": {
    "promptTokenCount": 122,
    "candidatesTokenCount": 526,
    "totalTokenCount": 1976,
    "thoughtsTokenCount": 1328,
    "promptTokensDetails": [
      {
        "modality": "TEXT",
        "tokenCount": 122
      }
    ]
  }
}
修改于 2025-11-19 12:49:50
上一页
Gemini生图
下一页
快速教学-完整流程一遍过
Built with