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

# Gemini 2.5 Flash Image (Stream)

> Generate an image with Gemini 2.5 Flash Image in SSE streaming mode. The endpoint returns newline-delimited Server-Sent Events. Thinking chunks (thought=true) are sent first, then image chunks with inlineData, then a usage chunk.



## OpenAPI

````yaml en/api-reference/model-api/google/openapi/gemini-2-5-flash-image-stream/openapi.yaml POST /v1beta/models/gemini-2.5-flash-image:streamGenerateContent
openapi: 3.1.0
info:
  title: Gemini 2.5 Flash Image (streaming)
  description: Call Google Gemini 2.5 Flash Image streaming image generation
  version: 1.0.0
servers:
  - url: https://ai.cubeuaeai.com
security: []
paths:
  /v1beta/models/gemini-2.5-flash-image:streamGenerateContent:
    post:
      summary: Image generation (streaming)
      description: >
        Generate an image with Gemini 2.5 Flash Image in SSE streaming mode. The
        endpoint returns newline-delimited Server-Sent Events. Thinking chunks
        (thought=true) are sent first, then image chunks with inlineData, then
        usage statistics chunk。
      operationId: Gemini25FlashImageStreamGenerateContent
      parameters:
        - name: key
          in: query
          description: API key
          required: true
          schema:
            type: string
          example: YOUR_API_KEY
        - name: alt
          in: query
          description: >-
            Set to sse to explicitly enable SSE mode (optional; streaming is the
            default behavior of this endpoint)
          required: false
          schema:
            type: string
            enum:
              - sse
          example: sse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - contents
                - generationConfig
              properties:
                contents:
                  type: array
                  description: >
                    Array of conversation turns. Each turn includes role and
                    parts. A part can be a text prompt or inline_data Image
                    (base64). To pass a reference image, include both a text
                    part and inline_data part。
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        enum:
                          - user
                          - model
                        example: user
                      parts:
                        type: array
                        description: >
                          List of content parts. Put text and inline_data in the
                          same array to send a prompt and a reference image
                          together.
                        items:
                          type: object
                          properties:
                            text:
                              type: string
                              description: Text prompt
                              example: Generate an image of a sunset in the mountains
                            inline_data:
                              type: object
                              description: >
                                Base64-encoded reference image (snake_case in
                                the request body). Note: in streaming responses
                                the field name is inlineData (camelCase).
                              properties:
                                mime_type:
                                  type: string
                                  description: >-
                                    Image MIME type Type. Supported: image/jpeg,
                                    image/png, image/webp
                                  enum:
                                    - image/jpeg
                                    - image/png
                                    - image/webp
                                  example: image/jpeg
                                data:
                                  type: string
                                  description: Base64-encoded image data.
                                  example: >-
                                    iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                  example:
                    - role: user
                      parts:
                        - text: Generate an image of a sunset in the mountains
                generationConfig:
                  type: object
                  required:
                    - responseModalities
                  properties:
                    responseModalities:
                      type: array
                      description: >
                        Output modalities. Use ["IMAGE"] to return images only,
                        or ["TEXT", "IMAGE"] to return both a caption and an
                        image.
                      items:
                        type: string
                        enum:
                          - TEXT
                          - IMAGE
                      example:
                        - TEXT
                        - IMAGE
                    imageConfig:
                      type: object
                      description: Image generation configuration
                      properties:
                        aspectRatio:
                          type: string
                          description: Aspect ratio of the generated image.
                          enum:
                            - '1:1'
                            - '4:3'
                            - '3:4'
                            - '16:9'
                            - '9:16'
                          example: '16:9'
                        imageSize:
                          type: string
                          description: >
                            Resolution of the generated image. 1K ≈ 1024px, 2K ≈
                            2048px, 4K ≈ 4096px (longest side).
                          enum:
                            - 1K
                            - 2K
                            - 4K
                          example: 1K
      responses:
        '200':
          description: >
            Streaming SSE response. Each line starts with "data:" followed by a
            JSON chunk. Three chunk types are sent in order: (1) thinking chunk
            — parts[0].thought is true; (2) image chunk — parts[0].inlineData
            contains mimeType and base64 data (camelCase); (3) final usage chunk
            — top-level usageMetadata, including thoughtsTokenCount。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamChunk'
              example:
                candidates:
                  - content:
                      role: model
                      parts:
                        - inlineData:
                            mimeType: image/png
                            data: >-
                              iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
                usageMetadata:
                  trafficType: ON_DEMAND
                modelVersion: gemini-2.5-flash-image
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
components:
  schemas:
    StreamChunk:
      type: object
      description: >
        A single SSE chunk. There are three types: thinking chunks
        (parts[].thought=true), image chunks (parts[].inlineData), and usage
        chunks (no candidates).
      properties:
        candidates:
          type: array
          description: >-
            Present in thinking chunks and image chunks; omitted from the final
            usage chunk.
          items:
            type: object
            properties:
              content:
                type: object
                properties:
                  role:
                    type: string
                    example: model
                  parts:
                    type: array
                    items:
                      type: object
                      properties:
                        text:
                          type: string
                          description: Thinking text (present only in thinking chunks)
                        thought:
                          type: boolean
                          description: When true, this part is an internal thinking chunk
                          example: true
                        inlineData:
                          type: object
                          description: >
                            Generated image data (camelCase; present only in
                            image chunks). Note: the request body uses
                            inline_data (snake_case).
                          properties:
                            mimeType:
                              type: string
                              example: image/png
                            data:
                              type: string
                              description: Base64-encoded generated image
                              example: >-
                                iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==
        usageMetadata:
          type: object
          description: >-
            Token usage. The final chunk includes full details, including
            thoughtsTokenCount.
          properties:
            promptTokenCount:
              type: integer
              example: 8
            candidatesTokenCount:
              type: integer
              example: 1120
            totalTokenCount:
              type: integer
              example: 1392
            thoughtsTokenCount:
              type: integer
              description: >-
                Tokens consumed by internal thinking (present only in the final
                usage chunk)
              example: 264
            trafficType:
              type: string
              example: ON_DEMAND
            promptTokensDetails:
              type: array
              items:
                type: object
                properties:
                  modality:
                    type: string
                    example: TEXT
                  tokenCount:
                    type: integer
                    example: 8
            candidatesTokensDetails:
              type: array
              items:
                type: object
                properties:
                  modality:
                    type: string
                    example: IMAGE
                  tokenCount:
                    type: integer
                    example: 1120
        modelVersion:
          type: string
          example: gemini-2.5-flash-image
        createTime:
          type: string
          example: '2025-01-01T00:00:00Z'
        responseId:
          type: string
          example: abc123
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
            message:
              type: string
            status:
              type: string

````