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

# Gemini streamGenerateContent

> Google Gemini `streamGenerateContent` relayed by Omniall AI.

**Path:** `POST https://api.omniall.ai/v1beta/models/{model}:streamGenerateContent`

Streaming native Gemini call (SSE).

Auth: `Authorization: Bearer sk-...`, or `x-goog-api-key` / `?key=`.

### Scenarios
- **Vision**: `inlineData` image parts
- **Files**: `fileData.fileUri`
- **Grounding / web**: `tools: [{ googleSearch: {} }]` when supported
- **Agent**: `functionDeclarations`
- **Image generation**: `generationConfig.responseModalities` including `IMAGE`

Official reference: https://ai.google.dev/api/generate-content




## OpenAPI

````yaml openapi/xgapi-public.yaml POST /v1beta/models/{model}:streamGenerateContent
openapi: 3.0.3
info:
  title: Omniall AI Public API
  description: >-
    Omniall AI public API. Website: https://omniall.ai — API host:
    https://api.omniall.ai — Model Square: https://omniall.ai/pricing
  version: 1.1.0
servers:
  - url: https://api.omniall.ai
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Models
    description: List models available to your API key.
  - name: ChatGPT Chat Completions
    x-group: ChatGPT
    description: OpenAI Chat Completions (`POST /v1/chat/completions`).
  - name: Responses
    description: OpenAI Responses API (`POST /v1/responses`).
  - name: Claude
    description: Anthropic Messages API (`POST /v1/messages`).
  - name: Gemini
    description: Google Gemini generateContent / streamGenerateContent.
  - name: Images
    description: >-
      Image generation (OpenAI Images), vendor guides, and Midjourney proxy
      APIs.
  - name: Video
    description: Async video tasks.
  - name: Audio
    description: Speech and related audio APIs.
  - name: Rerank
    description: Document reranking.
paths:
  /v1beta/models/{model}:streamGenerateContent:
    post:
      tags:
        - Gemini
      summary: Gemini streamGenerateContent
      description: >
        Google Gemini `streamGenerateContent` relayed by Omniall AI.


        **Path:** `POST
        https://api.omniall.ai/v1beta/models/{model}:streamGenerateContent`


        Streaming native Gemini call (SSE).


        Auth: `Authorization: Bearer sk-...`, or `x-goog-api-key` / `?key=`.


        ### Scenarios

        - **Vision**: `inlineData` image parts

        - **Files**: `fileData.fileUri`

        - **Grounding / web**: `tools: [{ googleSearch: {} }]` when supported

        - **Agent**: `functionDeclarations`

        - **Image generation**: `generationConfig.responseModalities` including
        `IMAGE`


        Official reference: https://ai.google.dev/api/generate-content
      operationId: geminiStreamGenerateContent
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
            example: gemini-2.0-flash
          description: Gemini model id (as exposed in Model Square / GET /v1/models).
        - name: key
          in: query
          required: false
          schema:
            type: string
          description: Optional Gemini-style API key query param.
        - name: x-goog-api-key
          in: header
          required: false
          schema:
            type: string
          description: Optional Gemini-style API key header.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiGenerateContentRequest'
            examples:
              basic:
                summary: Basic generateContent
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Hello Gemini
              vision:
                summary: Image understanding
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Caption this image
                        - inlineData:
                            mimeType: image/jpeg
                            data: /9j/4AAQ...
              file:
                summary: File URI analysis
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Summarize the PDF
                        - fileData:
                            mimeType: application/pdf
                            fileUri: https://example.com/doc.pdf
              google_search:
                summary: Google Search grounding
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Who won the latest F1 race?
                  tools:
                    - googleSearch: {}
              function_calling:
                summary: Function calling (agent)
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Weather in Paris?
                  tools:
                    - functionDeclarations:
                        - name: get_weather
                          description: Get weather
                          parameters:
                            type: object
                            properties:
                              city:
                                type: string
                            required:
                              - city
      responses:
        '200':
          description: Gemini response JSON (or SSE for streamGenerateContent).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeminiGenerateContentResponse'
        '400':
          description: Invalid request body or unsupported parameter for the model.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '401':
          description: Missing or invalid API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
              example:
                error:
                  message: '无效的令牌 (request id: ...)'
                  type: new_api_error
                  code: ''
        '403':
          description: Forbidden (banned user, IP allowlist, group access).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '429':
          description: Rate limited.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
        '500':
          description: Upstream or gateway internal error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenAIErrorResponse'
components:
  schemas:
    GeminiGenerateContentRequest:
      type: object
      required:
        - contents
      description: >-
        Native Gemini `generateContent` request body, relayed by Omniall AI. One
        `contents` turn is the minimum; add prior user/model turns for
        multi-turn chat.
      properties:
        contents:
          type: array
          items:
            type: object
            properties:
              role:
                type: string
                enum:
                  - user
                  - model
                description: >-
                  Who produced this turn. `user` = your application / end user
                  input; `model` = previous Gemini assistant output (include
                  these when continuing a multi-turn chat so the model has
                  context).
              parts:
                type: array
                items:
                  type: object
                  properties:
                    text:
                      type: string
                      description: >-
                        Plain text for this part (prompt, question, or prior
                        model reply). Example: "Describe this image".
                      example: Describe this image
                    inlineData:
                      type: object
                      properties:
                        mimeType:
                          type: string
                          example: image/jpeg
                          description: >-
                            IANA MIME type of the binary data. Common values:
                            `image/jpeg`, `image/png`, `image/webp`,
                            `application/pdf`, `audio/mpeg`. Must match the real
                            file type or the model may reject the part.
                        data:
                          type: string
                          description: >-
                            Raw file bytes encoded as Base64 **without** a
                            `data:` URL prefix. Do not include
                            `data:image/jpeg;base64,` here—only the Base64
                            payload. Large files increase request size and
                            latency; keep images reasonably sized.
                          example: /9j/4AAQSkZJRgABAQ...
                      description: >-
                        Inline binary media (image, audio, PDF, etc.) encoded as
                        Base64. Prefer this when you have file bytes available
                        and no public URL.
                    fileData:
                      type: object
                      properties:
                        mimeType:
                          type: string
                          description: >-
                            MIME type of the remote file (same rules as
                            `inlineData.mimeType`).
                          example: application/pdf
                        fileUri:
                          type: string
                          description: >-
                            Publicly reachable file URI/URL. Must be
                            downloadable without login cookies. Prefer HTTPS.
                          example: https://example.com/report.pdf
                      description: >-
                        Reference to a remote file instead of inlining Base64.
                        Use when the file is already reachable by URL / URI that
                        the upstream accepts.
                description: >-
                  One or more content parts for this turn. A turn can mix text
                  and media (for example text + an image). At least one part is
                  required.
            description: A single conversation turn.
          description: >-
            Ordered conversation turns sent to Gemini. Each item is one message
            from either the user or the model. For a first request, usually a
            single `user` turn is enough.
        systemInstruction:
          type: object
          properties:
            parts:
              type: array
              items:
                type: object
                additionalProperties: true
              description: System instruction parts (usually one text part).
          description: >-
            Optional system-level instruction that steers model behavior for the
            whole request (persona, output format, safety rules). Not counted as
            a user/model turn in `contents`.
        tools:
          type: array
          description: >-
            Optional tools the model may call. Examples: `{ "googleSearch": {}
            }` for grounding/web search (when enabled), or `{
            "functionDeclarations": [ ... ] }` for your own agent functions.
            Availability depends on the model/channel.
          items:
            type: object
            additionalProperties: true
        toolConfig:
          type: object
          additionalProperties: true
          description: >-
            Controls how tools are selected (for example function-calling mode).
            Pass through as Gemini `toolConfig` when you need to force/auto
            function calls.
        generationConfig:
          type: object
          properties:
            temperature:
              type: number
              description: >-
                Randomness of the answer. Higher = more creative/varied; lower =
                more deterministic. Typical range about 0–2 depending on model.
            topP:
              type: number
              description: >-
                Nucleus sampling: only tokens within the top probability mass
                `p` are considered. Lower values make output more focused.
            topK:
              type: integer
              description: >-
                Only sample from the top-K tokens. Smaller K = more conservative
                wording.
            maxOutputTokens:
              type: integer
              description: >-
                Hard cap on how many tokens the model may generate in the
                response. Increase for long answers; decrease to control
                cost/latency.
            responseMimeType:
              type: string
              description: >-
                Desired MIME type of the model text response, e.g. `text/plain`
                or `application/json` for JSON-oriented outputs when supported.
            responseModalities:
              type: array
              items:
                type: string
              description: >-
                Requested response modalities. For image generation include
                `IMAGE`, e.g. `["TEXT","IMAGE"]` or `["IMAGE"]`.
              example:
                - TEXT
                - IMAGE
            thinkingConfig:
              type: object
              additionalProperties: true
              description: >-
                Optional thinking/reasoning controls for models that support
                them (channel/model dependent).
            imageConfig:
              type: object
              description: >-
                Image output settings when `responseModalities` includes
                `IMAGE`. Snake_case aliases are also accepted.
              properties:
                aspectRatio:
                  type: string
                  description: >-
                    Output aspect ratio, e.g. `1:1`, `16:9`, `9:16`, `3:4`,
                    `4:3`.
                  enum:
                    - '1:1'
                    - '2:3'
                    - '3:2'
                    - '3:4'
                    - '4:3'
                    - '4:5'
                    - '5:4'
                    - '9:16'
                    - '16:9'
                    - '21:9'
                  example: '16:9'
                imageSize:
                  type: string
                  description: 'Resolution tier: `1K` / `2K` / `4K`.'
                  enum:
                    - 1K
                    - 2K
                    - 4K
                  example: 2K
          description: Sampling and output controls for this generation.
        safetySettings:
          type: array
          items:
            type: object
            additionalProperties: true
          description: >-
            Per-category safety thresholds (harassment, hate, sexual, dangerous
            content, etc.). Use when you need stricter or looser filtering than
            defaults.
    GeminiGenerateContentResponse:
      type: object
      properties:
        candidates:
          type: array
          items:
            type: object
            properties:
              content:
                type: object
                properties:
                  role:
                    type: string
                    description: Usually `model`.
                  parts:
                    type: array
                    items:
                      type: object
                      additionalProperties: true
                    description: >-
                      Answer parts (`text`, inline images, function calls,
                      etc.).
                description: Model message content for this candidate.
              finishReason:
                type: string
                description: >-
                  Why generation stopped (e.g. STOP, MAX_TOKENS, SAFETY). Check
                  this if the answer looks truncated or empty.
            description: A single candidate.
          description: One or more candidate replies. Usually use `candidates[0]`.
        usageMetadata:
          type: object
          properties:
            promptTokenCount:
              type: integer
              description: Tokens in the request (contents + system + tools, etc.).
            candidatesTokenCount:
              type: integer
              description: Tokens generated in the response.
            totalTokenCount:
              type: integer
              description: Sum of prompt and candidates tokens.
          description: Token usage for billing/debugging.
      description: >-
        Gemini generateContent response. Read the first candidate’s
        `content.parts` for the answer text/images.
    OpenAIErrorResponse:
      type: object
      description: OpenAI-style error envelope returned on auth/request failures.
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
          properties:
            message:
              type: string
              description: >-
                Human-readable error. The gateway may append a request id for
                support.
            type:
              type: string
              description: Error type, commonly `new_api_error`.
              example: new_api_error
            code:
              type: string
              description: >-
                Optional machine-readable code (e.g. `access_denied`). May be an
                empty string.
          description: Error object.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: 'Use Authorization: Bearer sk-... from https://omniall.ai/dashboard'

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.