Introduction

文本

Gemini 2.5 FlashGemini 2.5 ProGemini 3.1 Flash Lite PreviewGemini 3.1 Pro PreviewGemini 3.5 Flash

图片

视频

zwmaaszwmaas
开始使用API 参考
Gemini

Gemini 3.5 Flash · 对话补全

文本 / Gemini / Gemini 3.5 Flash / 对话补全

POST/v1/chat/completions

请求参数

Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接你的 API Key。

Authorization: Bearer ****************
Header 参数
Content-Typestring可选
application/json
Acceptstring可选
application/json
Body 参数application/json必填
modelstring必需
模型 ID,固定为 `gemini-3.5-flash`
messagesarray[object]必需
对话消息列表,每条含 `role`(system / user / assistant)与 `content`
streambool可选
是否流式返回(SSE),默认 `false`
temperaturenumber可选
采样温度,越大越随机
top_pnumber可选
核采样,与 `temperature` 二选一。范围 `0`–`1`
max_tokensint可选
最大生成 token 数
nint可选
生成的候选回复数,默认 `1`
stoparray可选
停止序列;命中任一即停止输出
presence_penaltynumber可选
对已出现过的 token 施加惩罚以提升新意。范围 `-2`–`2`
frequency_penaltynumber可选
按出现频率惩罚 token 以减少重复。范围 `-2`–`2`
reasoning_effortstring可选
思考型模型的推理深度:`low` / `medium` / `high`
toolsarray可选
工具 / 函数定义(function calling)
tool_choicestring/object可选
是否及调用哪个工具:`auto` / `none` / 指定工具
response_formatobject可选
约束输出格式,例如强制输出 JSON 对象
extra_bodyobject可选
厂商专有选项(如 `thinking_config`),经 `extra_body` 透传
示例
{  "model": "gemini-3.5-flash",  "messages": [    {      "role": "user",      "content": "你好,介绍一下你自己"    }  ]}

请求示例代码

curl https://api.hotrouter.ai/v1/chat/completions \  -H "Authorization: Bearer $API_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "gemini-3.5-flash",    "messages": [      {        "role": "user",        "content": "你好,介绍一下你自己"      }    ]  }'

返回响应

200 · 成功
idstring必需
本次响应的唯一 id
objectstring必需
对象类型
createdinteger必需
创建时间戳(秒)
modelstring必需
实际使用的模型
choicesarray[object]必需
生成结果列表
usageobject必需
本次调用的 token 用量
示例
{  "id": "chatcmpl-xxx",  "object": "chat.completion",  "created": 1730000000,  "model": "gemini-3.5-flash",  "choices": [    {      "index": 0,      "message": {        "role": "assistant",        "content": "你好!很高兴见到你……"      },      "finish_reason": "stop"    }  ],  "usage": {    "prompt_tokens": 12,    "completion_tokens": 24,    "total_tokens": 36  }}

On this page

请求参数请求示例代码返回响应
{
  "model": "gemini-3.5-flash",
  "messages": [
    {
      "role": "user",
      "content": "你好,介绍一下你自己"
    }
  ]
}
curl https://api.hotrouter.ai/v1/chat/completions \
  -H "Authorization: Bearer $API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gemini-3.5-flash",
    "messages": [
      {
        "role": "user",
        "content": "你好,介绍一下你自己"
      }
    ]
  }'
{
  "id": "chatcmpl-xxx",
  "object": "chat.completion",
  "created": 1730000000,
  "model": "gemini-3.5-flash",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!很高兴见到你……"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 24,
    "total_tokens": 36
  }
}