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

> ## Agent Instructions
> Public hosts only: console https://omnimux.ai/dashboard · API https://api.omnimux.ai · docs https://docs.omnimux.ai.
> Gateway auth is Authorization: Bearer sk-… on https://api.omnimux.ai/v1 (OpenAI-compatible Chat Completions and related paths).
> Discover pages from /llms.txt; full site dump /llms-full.txt; product skill /skill.md; docs search MCP /mcp. Prefer .md page URLs for Markdown.
> Default docs locale is en; zh mirrors the same relative paths. Do not invent model ids not present on live pricing or the complete API pages.

# Gemini · 原生流式理解

> 使用原生事件流接收生成内容并检查最终结果和用量。

* 型号：`gemini-4-argon`、`gemini-4-hydrogen`、`gemini-4-neon`、`gemini-4-carbon`；请求地址需带 `alt=sse`。
* 请求正文与[原生多模态理解](https://docs.omnimux.ai/zh/api-reference/text-series/gemini/native-generate.md)相同。
* 读取 `data:` 事件中的原生回复片段，等待正常结束并检查 `finishReason` 与最终可用的 `usageMetadata`。
* 已收到部分文字不能证明完整成功；中断后先核对结果与费用，避免重复发起。

采用结构化输出时，在拼接完整文字后同样须校验实际内容与字段类型。参数已传入或流正常结束，不代表内容一定符合 `responseSchema`。

## 用量与错误

累计用量快照不逐条相加。输入含已报告工具输入，输出含已报告思考，缓存是输入子集。费用以已公布账户价格与最终结算为准；自动切换服务线路不会改变该模型的已公布售价。余额不足除 `402` 外，也可能返回 `403` 和 `insufficient_user_quota`。


## OpenAPI

````yaml openapi/ops/gemini/native.json POST /v1beta/models/{model}:streamGenerateContent
openapi: 3.1.0
info:
  title: Gemini · Native multimodal text
  version: 1.0.0
  description: >-
    Native Gemini content requests with system instructions, media input, text
    and structured output on OmniMux.
servers:
  - url: https://api.omnimux.ai
security:
  - BearerAuth: []
paths:
  /v1beta/models/{model}:streamGenerateContent:
    post:
      summary: Gemini native streaming text generation
      description: >-
        Use the same native request body with alt=sse. Read complete data events
        and inspect final finishReason and usageMetadata.
      operationId: streamGeminiNativeText
      parameters:
        - name: model
          in: path
          required: true
          schema:
            type: string
            enum:
              - gemini-4-argon
              - gemini-4-hydrogen
              - gemini-4-neon
              - gemini-4-carbon
        - name: alt
          in: query
          required: true
          schema:
            type: string
            enum:
              - sse
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NativeRequest'
      responses:
        '200':
          description: SSE data events containing native response chunks
          content:
            text/event-stream:
              schema:
                type: string
              example: >+
                data:
                {"candidates":[{"content":{"role":"model","parts":[{"text":"Hello"}]}}]}


                data:
                {"candidates":[{"finishReason":"STOP"}],"usageMetadata":{"promptTokenCount":74,"candidatesTokenCount":6,"thoughtsTokenCount":115,"totalTokenCount":195}}

        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/InsufficientQuota'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          $ref: '#/components/responses/InternalError'
        '502':
          $ref: '#/components/responses/UpstreamError'
        '503':
          $ref: '#/components/responses/Unavailable'
components:
  schemas:
    NativeRequest:
      type: object
      required:
        - contents
      properties:
        systemInstruction:
          type: object
          required:
            - parts
          properties:
            parts:
              type: array
              items:
                $ref: '#/components/schemas/TextPart'
          description: >-
            Task framework and scope; media content is data, not a
            higher-priority instruction
        contents:
          type: array
          minItems: 1
          items:
            $ref: '#/components/schemas/NativeContent'
        generationConfig:
          type: object
          properties:
            thinkingConfig:
              type: object
              properties:
                thinkingLevel:
                  type: string
                  enum:
                    - low
                    - medium
                    - high
                    - xhigh
                  description: >-
                    Thinking effort level: hydrogen and neon support
                    low/medium/high/xhigh; carbon supports low/medium/high;
                    argon reference documents low.
            maxOutputTokens:
              type: integer
              minimum: 1
              example: 2048
              description: >-
                Combined thinking and visible-output budget. This example value
                is not a model maximum.
            responseMimeType:
              type: string
              enum:
                - application/json
            responseSchema:
              type: object
              description: >-
                Native Schema object for structured text, used with
                responseMimeType=application/json.
        tools:
          type: array
          items:
            type: object
            properties:
              functionDeclarations:
                type: array
                items:
                  type: object
                  required:
                    - name
                    - parameters
                  properties:
                    name:
                      type: string
                    description:
                      type: string
                    parameters:
                      type: object
          description: >-
            Function declarations for a single-turn function-call response. The
            returned functionCall asks the client to execute the function; it
            does not run the function.
        toolConfig:
          type: object
          properties:
            functionCallingConfig:
              type: object
              properties:
                mode:
                  type: string
                  enum:
                    - ANY
                allowedFunctionNames:
                  type: array
                  items:
                    type: string
      example:
        systemInstruction:
          parts:
            - text: Respond concisely.
        contents:
          - role: user
            parts:
              - text: Hello.
        generationConfig:
          maxOutputTokens: 2048
    TextPart:
      type: object
      required:
        - text
      properties:
        text:
          type: string
    NativeContent:
      type: object
      required:
        - parts
      properties:
        role:
          type: string
          enum:
            - user
        parts:
          type: array
          minItems: 1
          items:
            oneOf:
              - $ref: '#/components/schemas/TextPart'
              - $ref: '#/components/schemas/InlinePart'
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
            type:
              type: string
            code:
              oneOf:
                - type: string
                - type: integer
    InlinePart:
      type: object
      required:
        - inlineData
      properties:
        inlineData:
          type: object
          required:
            - mimeType
            - data
          properties:
            mimeType:
              type: string
              enum:
                - image/png
                - video/mp4
                - application/pdf
            data:
              type: string
              contentEncoding: base64
              description: >-
                Complete original media bytes encoded as base64, without a
                data-URL prefix
  responses:
    BadRequest:
      description: Invalid or unsupported request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Missing or invalid OmniMux API token
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InsufficientQuota:
      description: Insufficient available quota
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Forbidden:
      description: >-
        Request/model access is not allowed; this native surface may also return
        insufficient_user_quota as HTTP 403. Inspect the error code and message
        rather than assuming a permission problem.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFound:
      description: Requested resource or model is unavailable
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Rate limit reached
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    InternalError:
      description: Gateway error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UpstreamError:
      description: Upstream error or incomplete upstream result
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unavailable:
      description: No available accepted route
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: OmniMux API token

````

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