> ## Documentation Index
> Fetch the complete documentation index at: https://docs.anyfast.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# gemini-2.5-pro-stream

> 以流式方式生成模型回复，使用 SSE 实时返回。



## OpenAPI

````yaml zh/api-reference/model-api/google/openapi/gemini-2-5-pro-stream/openapi.yaml POST /v1beta/models/gemini-2.5-pro:streamGenerateContent
openapi: 3.1.0
info:
  title: Gemini 2.5 Pro (Stream)
  description: 通过 Anyfast 代理调用 Google Gemini 2.5 Pro (Stream)
  version: 1.0.0
servers:
  - url: https://www.anyfast.ai
security: []
paths:
  /v1beta/models/gemini-2.5-pro:streamGenerateContent:
    post:
      summary: 文本生成（流式）
      description: 以流式方式生成模型回复，使用 SSE 实时返回。
      operationId: Gemini25ProStreamStreamGenerateContent
      parameters:
        - name: key
          in: query
          description: API 密钥
          required: true
          schema:
            type: string
          example: YOUR_API_KEY
        - name: alt
          in: query
          description: 设为 sse 以启用 SSE 流式返回
          required: false
          schema:
            type: string
          example: sse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
              properties:
                contents:
                  type: array
                  description: 对话内容数组，包含用户和模型的消息。
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - model
                        example: user
                      parts:
                        type: array
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: 文本内容
                  example:
                    - role: user
                      parts:
                        - text: 你好，请介绍一下你自己。
                systemInstruction:
                  type: object
                  description: 系统指令
                  properties:
                    parts:
                      type: array
                      items:
                        type: object
                        properties:
                          text:
                            type: string
                  example:
                    parts:
                      - text: 你是一个有帮助的助手。
                safetySettings:
                  type: array
                  description: 安全过滤设置
                  items:
                    type: object
                    properties:
                      category:
                        type: string
                      threshold:
                        type: string
                generationConfig:
                  type: object
                  properties:
                    temperature:
                      type: number
                      minimum: 0
                      maximum: 2
                      default: 1
                      description: 采样温度，值越高输出越随机。
                      example: 1
                    topP:
                      type: number
                      minimum: 0
                      maximum: 1
                      default: 1
                      description: 核采样阈值。
                    thinkingConfig:
                      type: object
                      description: 思考配置
                      properties:
                        includeThoughts:
                          type: boolean
                          default: true
                          description: 是否包含思考过程
                        thinkingBudget:
                          type: integer
                          default: 26240
                          description: 思考 Token 预算
      responses:
        '200':
          description: 成功生成流式回复
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateContentResponse'
        '400':
          description: 请求参数有误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: 未授权
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    GenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          items:
            type: object
            properties:
              content:
                type: object
                properties:
                  parts:
                    type: array
                    items:
                      type: object
                      properties:
                        text:
                          type: string
                          example: 你好！
                  role:
                    type: string
                    example: model
              finishReason:
                type: string
                example: STOP
        usageMetadata:
          type: object
          properties:
            promptTokenCount:
              type: integer
            candidatesTokenCount:
              type: integer
            totalTokenCount:
              type: integer
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
            status:
              type: string

````