Poixe AI 提供的 Gemini 模型,如何开启思考模式?

Google 公司开发的 Gemini 2.5 模型经过训练,能够深入思考复杂问题,从而显著提升推理能力。

Poixe AI 平台提供的 Gemini 系列模型,尚未支持官方协议,而是采用的 Google 提供的 OpenAI 协议的接口,如果需要使用模型的思考功能,请参考本帖。

控制思考模式

参考官方文档:

注意:Gemini 2.5 Pro 和 2.5 Flash 默认开启思考功能。对于 2.5 Pro 型号,无法关闭推理功能。

Gemini API 附带一个“思考预算”参数,可让您精细控制模型的思考量。

与 Gemini API 不同,OpenAI API 提供三种思考控制级别:"low""medium""high",分别对应于 1,024、8,192 和 24,576 个令牌。

如果您想停用思考功能,可以将 reasoning_effort 设置为 "none"

Gemini 思考模型还会生成思考摘要,并且可以使用确切的思考预算。 您可以使用 extra_body 字段在请求中添加这些字段。

请注意,reasoning_effortthinking_budget 的功能重叠,因此不能同时使用。

示例代码

这里演示最原始的 Postman 中请求体的写法,如下:

{
  "model": "gemini-2.5-pro-preview-05-06",
  "messages": [
    {
      "role": "user",
      "content": "hi"
    }
  ],
  "extra_body":{
    "google": {
      "thinking_config": {
        "include_thoughts": true
      }
    }
  }
}

响应体:

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "<thought>**Processing a Simple Greeting**\n\nOkay, the user just said \"hi.\" That's a classic conversational opener, a simple greeting. My job is to respond appropriately, initiate a helpful interaction, and quickly understand what the user needs.\n\nFirst, I acknowledge the greeting. \"Hello!\" or \"Hi there!\" are good starting points. But a simple greeting alone isn't enough. I'm here to *help*. So, I need to couple that greeting with an offer of assistance.  \"How can I help you today?\" is a standard, tried-and-true prompt. It's direct, polite, and clearly communicates my purpose. I could also use \"What can I do for you?\" or \"How can I assist you today?\" to add variety.\n\nI considered a few different options: a friendly \"Hi there! What can I do for you today?\", a casual \"Hey! How can I help you?\", and even a more formal \"Hello! How can I assist you today?\". I like the balance of friendly and professional. I could also make it more specific: \"Hi there! How can I help you today? Is there something you'd like to know or create?\" I need to keep in mind, however, the user is starting a simple conversation, so I don't want to overwhelm them.\n\nUltimately, I'm going with a straightforward \"Hello! How can I help you today?\" It's effective, friendly, and instantly signals my willingness to assist. It directly addresses the user's initial input, fits the role of a helpful AI assistant, and gives the user a clear prompt to move the conversation forward. It's a solid, reliable response. That's a good place to begin.\n</thought>Hello! How can I help you today?",
                "extra_content": {
                    "google": {
                        "thought": true
                    }
                },
                "role": "assistant"
            }
        }
    ],
    "created": 1753455745,
    "id": "gZyDaI3cGdL_ugf8tsPYDg",
    "model": "gemini-2.5-pro-preview-05-06",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 632,
        "prompt_tokens": 2,
        "total_tokens": 634
    }
}

写在最后

如果您有任何的疑惑,请随时联系团队技术支持。

Poixe AI 官网:https://poixe.com

实际测试发现,Gemini 2.5 Pro 系列模型无法完全关闭思考(官方限制,包括 Gemini 官方协议)。

本帖将介绍一种替代访问,仅供参考。

上图来源:OpenAI 兼容性  |  Gemini API  |  Google AI for Developers

上图来源:Gemini 思考  |  Gemini API  |  Google AI for Developers

替代方案(减少思考过程)

调整 thinking_budget 参数,控制预算。以下的参数中,thinking_budget 的取值范围: 128 - 32768

// 请求体

{
  "model": "gemini-2.5-pro",
  "messages": [
    {
      "role": "user",
      "content": "hi"
    }
  ],
  "stream": false,
  "extra_body":{
    "google": {
      "thinking_config": {
        "thinking_budget": 128,
        "include_thoughts": true
      }
    }
  }
}

include_thoughts 参数用于控制是否显示思考过程。

// 响应体

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "<thought>**Understanding the Greeting**\n\nOkay, so the user just said \"hi.\" That's the starting point. I need to figure out what that means in the context of our interaction. It's pretty straightforward, though, right? It's a basic greeting, a conversational cue. They're trying to start a dialogue.  Essentially, they're signaling their willingness to interact. It's the linguistic equivalent of a nod and a smile, a friendly opener.  Now, the real work begins... how to respond effectively.\n</thought>Hi there! How can I help you today?",
                "extra_content": {
                    "google": {
                        "thought": true
                    }
                },
                "role": "assistant"
            }
        }
    ],
    "created": 1753875042,
    "id": "YgKKaNf-Osac1MkPpufCaA",
    "model": "gemini-2.5-pro",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 65,
        "prompt_tokens": 2,
        "total_tokens": 67
    }
}