Skip to content

Gemini 3.7 Flash ​

本页由 ModelFold 文档站根据上游官方 OpenAPI 文档同步生成。接口路径、参数、示例与官方保持一致;品牌与 API 域名已替换为 ModelFold。

接口 ​

POST /gemini/v1/models/gemini-3-7-flash:streamGenerateContent

完整 URL: https://ai.modelfold.online/gemini/v1/models/gemini-3-7-flash:streamGenerateContent

鉴权:所有请求都需要 Authorization: Bearer <API_KEY> 请求头。

WARNING

⚠️ 已被 Google 弃用,自动转发

Gemini 3.7 Flash 已被 Google 弃用。调用本接口的请求现由 Gemini 3.8 Flash 处理,与 Gemini 3.8 Flash 同价计费。请把接入改为 Gemini 3.8 Flash。

WARNING

⚠️ 仅支持对话调用

该模型目前仅支持对话调用,暂未适配 Agent 场景。若将其接入 Agent 使用,可能会出现请求报错或结果异常。

Streaming Support ​

Gemini 端点使用 streamGenerateContent 返回流式结果。函数调用结果会出现在 candidates[].content.parts[].functionCall 中。

Streaming Response Format:

  • Content-Type:text/event-stream。最后一个数据块带 usageMetadata 与 credits_consumed,随后是 data: [DONE]。
  • 函数调用会在 parts[].functionCall 中返回
  • 思考输出可能通过 thoughtSignature 和 usage 信息体现

Features ​

  • 使用 contents 进行标准对话。
  • 使用 googleSearch 启用联网搜索。
  • 使用 functionDeclarations 进行函数调用。
  • 使用 generationConfig.thinkingConfig 控制思考配置。

Request Notes ​

  • 使用 contents 作为主要输入字段。
  • 使用 tools.googleSearch 开启 Google Search。
  • 使用 tools.functionDeclarations 定义可调用函数。
  • 使用 generationConfig.thinkingConfig 控制思考输出与 thinking level。

Authentication ​

鉴权:请求头携带 Authorization: Bearer YOUR_API_KEY。

错误响应 ​

错误以 HTTP 200 返回,响应体为 {"code": <int>, "msg": "<原因>"}。读取 choices/candidates 前请先判断 code(200 为成功)。

请求参数 ​

请求体 (application/json) ​

参数类型必填说明
contentsarray&lt;object&gt;是Gemini 对话输入数组。
  contents[].rolestring是内容角色。 可选值:user / model。 示例:user。
  contents[].parts`array<objectobjectobject>`
tools`array<objectobject>`否
generationConfigobject否生成配置。
  generationConfig.thinkingConfigobject否思考配置。
    generationConfig.thinkingConfig.includeThoughtsboolean否是否包含思考输出。 示例:true。
    generationConfig.thinkingConfig.thinkingLevelstring否thinking level 等级。 可选值:low / high。 示例:high。
streamboolean否如果设为 true,以流式分块返回结果。 默认值:true。 示例:true。

请求示例 ​

bash
curl -X POST "https://ai.modelfold.online/gemini/v1/models/gemini-3-7-flash:streamGenerateContent" \
  -H "Authorization: Bearer $MODELFOLD_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "stream": true,
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "What is the weather in Beijing today?"
        }
      ]
    }
  ],
  "tools": [
    {
      "functionDeclarations": [
        {
          "name": "get_weather_forecast",
          "description": "Get the weather forecast for a given location",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "location": {
                "type": "STRING",
                "description": "The city name, e.g. Beijing"
              }
            },
            "required": [
              "location"
            ]
          }
        }
      ]
    }
  ],
  "generationConfig": {
    "thinkingConfig": {
      "includeThoughts": true,
      "thinkingLevel": "high"
    }
  }
}'
json
{
  "stream": true,
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "What is the weather in Beijing today?"
        }
      ]
    }
  ],
  "tools": [
    {
      "functionDeclarations": [
        {
          "name": "get_weather_forecast",
          "description": "Get the weather forecast for a given location",
          "parameters": {
            "type": "OBJECT",
            "properties": {
              "location": {
                "type": "STRING",
                "description": "The city name, e.g. Beijing"
              }
            },
            "required": [
              "location"
            ]
          }
        }
      ]
    }
  ],
  "generationConfig": {
    "thinkingConfig": {
      "includeThoughts": true,
      "thinkingLevel": "high"
    }
  }
}

响应 ​

200 — 请求成功。 ​

参数类型必填说明
candidatesarray&lt;object&gt;否候选结果列表
  candidates[].contentobject否—
    candidates[].content.rolestring否示例:model。
    candidates[].content.partsarray&lt;object&gt;否—
      candidates[].content.parts[].functionCallobject否函数调用结构
      candidates[].content.parts[].thoughtSignaturestring否思考签名字段 示例:Es8CCswCAb4example。
      candidates[].content.parts[].textstring否文本输出
  candidates[].finishReasonstring否候选结束原因 示例:STOP。
modelVersionstring否返回的模型版本,可能不返回。 示例:gemini-3-7-flash。
usageMetadataobject否Token 用量信息
  usageMetadata.candidatesTokenCountinteger否示例:18。
  usageMetadata.thinkingTokenCountinteger否示例:55。
  usageMetadata.totalTokenCountinteger否示例:325。
  usageMetadata.promptTokenCountinteger否示例:252。
credits_consumednumber否本次请求消耗的 credits 示例:0.01。
json
{
  "candidates": [
    {
      "content": {
        "role": "model",
        "parts": [
          {
            "functionCall": {
              "args": {
                "location": "Beijing"
              },
              "name": "get_weather_forecast",
              "id": "gp737npz"
            },
            "thoughtSignature": "Es8CCswCAb4example"
          }
        ]
      },
      "finishReason": "STOP"
    }
  ],
  "modelVersion": "gemini-3-7-flash",
  "usageMetadata": {
    "candidatesTokenCount": 18,
    "thinkingTokenCount": 55,
    "totalTokenCount": 325,
    "promptTokenCount": 252
  },
  "credits_consumed": 0.01
}

ModelFold — 一个 API,接入所有主流 AI 模型。