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

# Gemini generate content

> Text chat and image / PDF / audio / video recognition using the Gemini native API format

## Models you can use

| Model ID                 | Notes                                                   |
| ------------------------ | ------------------------------------------------------- |
| `gemini-3.1-pro-preview` | Gemini flagship — strong multimodal, very long context  |
| `gemini-2.5-pro`         | High-performance multimodal, up to 1M token context     |
| `gemini-2.5-flash`       | Fast, lightweight — optimized for high-volume workloads |

See [`GET /v1/models`](/api-reference/models/list-models) for the full list.

## Multi-turn conversations

Alternate `role: user` and `role: model` entries in the `contents` array
to build a multi-turn conversation.

## Media recognition

Add an `inlineData` entry in `parts` with a `mimeType` (e.g.
`image/jpeg`, `application/pdf`, `audio/mpeg`, `video/mp4`) and the
base64-encoded file data.

## Streaming

Replace `:generateContent` in the path with
`:streamGenerateContent?alt=sse` to switch to SSE streaming mode.

## Safety filtering

Use `safetySettings` to adjust the blocking threshold for each harm
category.

## System instructions

Pass a system-level prompt via `systemInstruction`, using the same
`parts` format as `contents`.


## OpenAPI

````yaml /openapi/chat.en.yaml post /v1beta/models/{model}:generateContent
openapi: 3.1.0
info:
  title: InfinityBlue API — Chat
  version: 1.0.0
  summary: Unified AI model API gateway — Chat endpoints
  description: >
    InfinityBlue is a unified API gateway for AI models. It exposes

    **OpenAI-, Google Gemini-, and Anthropic Claude-compatible** endpoints,

    backed by models from OpenAI, Google, DeepSeek, ByteDance (Seedance),

    Kuaishou (Kling), and more.


    You don't need to integrate each vendor separately — just point your

    base URL at InfinityBlue and keep using the official SDK you already know.


    ## Authentication


    Every request must include your API key in the header:


    ```

    Authorization: Bearer YOUR_API_KEY

    ```


    Create and manage your API keys in the
    [console](https://api.getinfinityblue.com/console).


    ## Endpoint format conventions


    | Path prefix | Compatible format |

    | --- | --- |

    | `/v1/*` | OpenAI (Chat Completions, Responses, Images, etc.) |

    | `/v1/messages` | Anthropic Claude Messages |

    | `/v1beta/models/*` | Google Gemini native |


    ## Model selection


    Pass any model ID in the `model` parameter. See

    [`GET /v1/models`](/api-reference/models/list-models)

    or the [pricing page](https://api.getinfinityblue.com/pricing)

    for the full list.
  contact:
    name: InfinityBlue
    url: https://getinfinityblue.com
servers:
  - url: https://api.getinfinityblue.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Chat
    description: |
      Text conversations, vision, tool calling, streaming, and reasoning
      models — all through a single chat endpoint.
paths:
  /v1beta/models/{model}:generateContent:
    post:
      tags:
        - Chat
      summary: Gemini generate content (text / media recognition)
      description: >
        Proxy native Gemini `generateContent` requests, supporting text chat

        and multimodal recognition (images, PDFs, audio, video).


        Path format: `/v1beta/models/{model_name}:generateContent`


        Streaming variant:
        `/v1beta/models/{model_name}:streamGenerateContent?alt=sse`


        ⚠️ Media content must be uploaded via `inlineData` as base64-encoded
        data.

        `fileData.fileUri` and the Google File API are not supported.
      operationId: geminiGenerateContent
      parameters:
        - name: model
          in: path
          description: Model name, e.g. `gemini-2.5-pro` or `gemini-2.5-flash`.
          required: true
          schema:
            type: string
            examples:
              - gemini-2.5-pro
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GeminiGenerateContentRequest'
            examples:
              text_chat:
                summary: Text chat
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Hi, introduce Gemini in one sentence.
              multi_turn:
                summary: Multi-turn conversation
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Hello
                    - role: model
                      parts:
                        - text: Great to meet you. What would you like to know?
                    - role: user
                      parts:
                        - text: >-
                            I have two dogs in my house. How many paws are in my
                            house?
              image_recognition:
                summary: Image recognition
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Tell me about the instrument in this image.
                        - inlineData:
                            mimeType: image/jpeg
                            data: <base64-encoded image data>
              pdf_recognition:
                summary: PDF recognition
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Can you add a few more lines to this poem?
                        - inlineData:
                            mimeType: application/pdf
                            data: <base64-encoded PDF data>
              audio_recognition:
                summary: Audio recognition
                value:
                  contents:
                    - role: user
                      parts:
                        - text: Please describe this audio file.
                        - inlineData:
                            mimeType: audio/mpeg
                            data: <base64-encoded audio data>
              video_recognition:
                summary: Video recognition
                value:
                  contents:
                    - role: user
                      parts:
                        - text: >-
                            Transcribe the audio from this video and provide
                            visual descriptions.
                        - inlineData:
                            mimeType: video/mp4
                            data: <base64-encoded video data>
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeminiGenerateContentResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Invalid or missing API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    GeminiGenerateContentRequest:
      type: object
      description: >-
        Gemini generateContent request body, used for both text chat and media
        recognition.
      properties:
        contents:
          type: array
          description: |
            Conversation contents in chronological order. Each element has a
            `role` (`user` or `model`) and a `parts` array of content fragments.
          items:
            type: object
            properties:
              role:
                type: string
                enum:
                  - user
                  - model
                description: Message role.
              parts:
                type: array
                description: >-
                  Content parts, which may include text, images, PDFs, audio, or
                  video.
                items:
                  type: object
                  properties:
                    text:
                      type: string
                      description: Text content.
                    inlineData:
                      type: object
                      description: >-
                        Base64-encoded media data for image, PDF, audio, or
                        video recognition.
                      properties:
                        mimeType:
                          type: string
                          description: |
                            Media MIME type, e.g. `image/jpeg`, `image/png`,
                            `application/pdf`, `audio/mpeg`, `video/mp4`.
                          examples:
                            - image/jpeg
                        data:
                          type: string
                          description: Base64-encoded media file data.
        generationConfig:
          type: object
          description: Generation parameter configuration.
          properties:
            temperature:
              type: number
              description: Sampling temperature, controlling output randomness.
            topP:
              type: number
              description: Nucleus sampling threshold.
            topK:
              type: integer
              description: >-
                Top-K sampling — the model considers only the K most probable
                tokens at each step.
            maxOutputTokens:
              type: integer
              description: Maximum number of tokens to generate in the response.
            stopSequences:
              type: array
              description: Stop sequences — generation halts when any of these is produced.
              items:
                type: string
        safetySettings:
          type: array
          description: >-
            Safety filter settings to adjust blocking thresholds per harm
            category.
          items:
            type: object
            properties:
              category:
                type: string
                description: Harm category, e.g. `HARM_CATEGORY_HARASSMENT`.
              threshold:
                type: string
                description: Blocking threshold, e.g. `BLOCK_NONE`, `BLOCK_ONLY_HIGH`.
        tools:
          type: array
          description: Tool list for function calling.
          items:
            type: object
        systemInstruction:
          type: object
          description: System-level instruction in the same format as a `contents` element.
          properties:
            parts:
              type: array
              description: System instruction content parts.
              items:
                type: object
                properties:
                  text:
                    type: string
                    description: System instruction text.
    GeminiGenerateContentResponse:
      type: object
      description: Gemini generateContent response body.
      properties:
        candidates:
          type: array
          description: List of candidate responses generated by the model.
          items:
            type: object
            properties:
              content:
                type: object
                description: Response content.
                properties:
                  role:
                    type: string
                    description: Role, typically `model`.
                  parts:
                    type: array
                    description: Content parts.
                    items:
                      type: object
                      properties:
                        text:
                          type: string
                          description: Text content.
              finishReason:
                type: string
                description: >-
                  Reason generation stopped, e.g. `STOP`, `MAX_TOKENS`,
                  `SAFETY`.
              safetyRatings:
                type: array
                description: Safety ratings per harm category.
                items:
                  type: object
                  properties:
                    category:
                      type: string
                      description: Harm category.
                    probability:
                      type: string
                      description: >-
                        Harm probability, e.g. `NEGLIGIBLE`, `LOW`, `MEDIUM`,
                        `HIGH`.
        usageMetadata:
          type: object
          description: Token usage statistics.
          properties:
            promptTokenCount:
              type: integer
              description: Tokens consumed by the prompt.
            candidatesTokenCount:
              type: integer
              description: Tokens consumed across all candidate responses.
            totalTokenCount:
              type: integer
              description: Total tokens consumed.
    ErrorResponse:
      type: object
      description: Standard error response.
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Error message.
              examples:
                - Invalid duration. Supported range is 4 to 15 seconds.
            type:
              type: string
              description: Error type.
              examples:
                - invalid_request_error
            param:
              type:
                - string
                - 'null'
              description: The parameter related to the error.
              examples:
                - seconds
            code:
              type:
                - string
                - 'null'
              description: Error code.
              examples:
                - invalid_duration
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: API Key
      description: >
        Bearer token authentication, format: `Authorization: Bearer sk-xxxxxx`.

        Get your API key in the
        [console](https://api.getinfinityblue.com/console).

````