Skip to content

文本生成+思考-流

POST https://az.gptplus5.com/v1beta/models/gemini-2.5-pro:streamGenerateContent

官方文档:https://ai.google.dev/gemini-api/docs/text-generation?hl=zh-cn#multi-turn-conversations

请求参数

Authorization

在 Header 添加参数Authorization,其值为在 Bearer 之后拼接 Token

示例:Authorization: Bearer ********************

Query 参数

参数名类型必需说明示例
keystring必需{{YOUR_API_KEY}}
altstring可选sse

Header 参数

参数名类型必需说明示例
Content-Typestring必需application/json

Body 参数 (application/json)

参数名类型必需说明
contentsarray[object]必需
  └ partsarray[object]可选

请求示例

json
{
  "contents": [
    {
      "parts": [
        {
          "text": "1+2+3+4+5+....+999?"
        }
      ],
      "role": "user"
    }
  ],
  "systemInstruction": {
    "parts": [
      {
        "text": "hi"
      }
    ],
    "role": "user"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ],
  "tools": [],
  "generationConfig": {
    "temperature": 1,
    "topP": 1,
    "thinkingConfig": {
      "includeThoughts": true,
      "thinkingBudget": 26240
    }
  }
}

cURL 示例

bash
curl --location -g --request POST 'https://az.gptplus5.com/v1beta/models/gemini-2.5-pro:streamGenerateContent?key=&alt=sse' \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data-raw '{
  "contents": [
    {
      "parts": [
        {
          "text": "1+2+3+4+5+....+999?"
        }
      ],
      "role": "user"
    }
  ],
  "systemInstruction": {
    "parts": [
      {
        "text": "hi"
      }
    ],
    "role": "user"
  },
  "safetySettings": [
    {
      "category": "HARM_CATEGORY_HATE_SPEECH",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_HARASSMENT",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
      "threshold": "OFF"
    },
    {
      "category": "HARM_CATEGORY_CIVIC_INTEGRITY",
      "threshold": "BLOCK_NONE"
    }
  ],
  "tools": [],
  "generationConfig": {
    "temperature": 1,
    "topP": 1,
    "thinkingConfig": {
      "includeThoughts": true,
      "thinkingBudget": 26240
    }
  }
}'

返回响应

🟢200成功

响应示例

json
{}