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

# /v1beta/models/{model}:streamGenerateContent

> Streams incremental Gemini generation events.

用于 Gemini 的流式文本生成和增量事件输出。

* 官方常见鉴权方式是 `x-goog-api-key: {API_KEY}`，也支持查询参数 API Key
* 请求体结构与 `generateContent` 基本一致，核心仍是 `contents`
* 返回内容是事件流而不是一次性 JSON，客户端需要按顺序拼接增量片段
* 停止原因和安全信息可能在后续 chunk 中才完整出现


## OpenAPI

````yaml POST /v1beta/models/{model}:streamGenerateContent
openapi: 3.1.0
info:
  title: OpenAPI Plant Store
  description: >-
    A sample API that uses a plant store as an example to demonstrate features
    in the OpenAPI specification
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api-vip.apigo.ai
security:
  - bearerAuth: []
paths:
  /v1beta/models/{model}:streamGenerateContent:
    post:
      summary: Gemini streamGenerateContent
      description: 以流式方式返回 Gemini 的增量生成事件。
      parameters:
        - name: model
          in: path
          description: Gemini model name.
          required: true
          schema:
            type: string
            example: gemini-2.5-pro
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiGenerateContentRequest'
      responses:
        '200':
          description: Successful Gemini streaming response
          content:
            text/event-stream:
              schema:
                type: string
              example: |+
                data: {"candidates":[{"content":{"parts":[{"text":"这里是第一段"}]}}]}

        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - googleApiKey: []
components:
  schemas:
    GeminiGenerateContentRequest:
      type: object
      required:
        - contents
      properties:
        contents:
          type: array
          items:
            $ref: '#/components/schemas/GeminiContent'
        systemInstruction:
          $ref: '#/components/schemas/GeminiContent'
        generationConfig:
          $ref: '#/components/schemas/GeminiGenerationConfig'
        safetySettings:
          type: array
          items:
            $ref: '#/components/schemas/GeminiSafetySetting'
        tools:
          type: array
          items:
            type: object
            additionalProperties: true
    Error:
      required:
        - error
        - message
      type: object
      properties:
        error:
          type: integer
          format: int32
        message:
          type: string
    GeminiContent:
      type: object
      properties:
        role:
          type: string
        parts:
          type: array
          items:
            $ref: '#/components/schemas/GeminiPart'
    GeminiGenerationConfig:
      type: object
      properties:
        temperature:
          type: number
          example: 0.7
        topP:
          type: number
        maxOutputTokens:
          type: integer
        responseMimeType:
          type: string
    GeminiSafetySetting:
      type: object
      properties:
        category:
          type: string
        threshold:
          type: string
    GeminiPart:
      type: object
      properties:
        text:
          type: string
        inlineData:
          $ref: '#/components/schemas/GeminiInlineData'
        fileData:
          $ref: '#/components/schemas/GeminiFileData'
    GeminiInlineData:
      type: object
      properties:
        mimeType:
          type: string
        data:
          type: string
    GeminiFileData:
      type: object
      properties:
        mimeType:
          type: string
        fileUri:
          type: string
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    googleApiKey:
      type: apiKey
      in: header
      name: x-goog-api-key

````