> ## 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.

# Chat image generation

## One endpoint, multiple use cases

`POST /v1/chat/completions` covers **text-to-image** and **image-to-image** (plus multi-image / PDF / short-video references). They differ only in `messages` content — not separate APIs.

| Use case | `messages[].content` |
| - | - |
| Text-to-image | Plain string, or only `type: text` |
| Image-to-image | `text` + `image_url` (one or more) |
| PDF reference (Banana 2.1) | `text` + `file` |
| Short video (Banana 2.1) | `text` + `video_url` (**string**) |

Gateway flow: Chat `messages` → download URL / decode data URL → Gemini `inlineData` → upstream `generateContent`.
Remote PDF / video URLs are supported; they are **not** forwarded as `fileUri`.

| Media | Content type | Value |
| - | - | - |
| Image | `image_url` | HTTPS URL or `data:image/...;base64,...` |
| PDF | `file` | `filename` + `file_data` (HTTPS URL or `data:application/pdf;base64,...`) |
| Video | `video_url` | **String** HTTPS URL or `data:video/mp4;base64,...` |

### PDF URL (complete)

```json theme={null}
{
  "model": "gemini-nano-banana-2.1",
  "stream": false,
  "extra_body": {
    "google": {
      "image_config": {
        "aspect_ratio": "3:2",
        "image_size": "1K"
      }
    }
  },
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Read the PDF. List labels, colors and shapes by page, then generate a reference-sheet image on a white background."
        },
        {
          "type": "file",
          "file": {
            "filename": "reference.pdf",
            "file_data": "https://example.com/reference.pdf"
          }
        }
      ]
    }
  ]
}
```

### Video URL (complete)

```json theme={null}
{
  "model": "gemini-nano-banana-2.1",
  "stream": false,
  "extra_body": {
    "google": {
      "image_config": {
        "aspect_ratio": "3:2",
        "image_size": "1K"
      }
    }
  },
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Watch the video. List scene elements in order, then generate a reference-sheet image."
        },
        {
          "type": "video_url",
          "video_url": "https://example.com/clip.mp4"
        }
      ]
    }
  ]
}
```

```bash theme={null}
curl --fail-with-body --max-time 180 \
  "https://api.omniall.ai/v1/chat/completions" \
  -H "Authorization: Bearer sk-xxx" \
  -H "Content-Type: application/json" \
  --data-binary @request.json
```

Notes: URLs must be publicly downloadable; default download limit is about 64MB per file; prefer short MP4 / small PDF. Pass `video_url` as a string, not `{ "url": "..." }`.

### Optional: Thinking

Banana 2.1 supports thinking levels `minimal` / `medium` (default) / `high` via `extra_body.google.thinking_config` (snake\_case):

```json theme={null}
"extra_body": {
  "google": {
    "image_config": { "aspect_ratio": "3:2", "image_size": "1K" },
    "thinking_config": {
      "thinking_level": "high",
      "include_thoughts": false
    }
  }
}
```

`include_thoughts` only controls whether thought text is returned; you can omit `thinking_config` for typical use. See [Overview · Thinking](/api-reference/image-gemini#optional-thinking-levels).


## OpenAPI

````yaml openapi/gemini-chat-image-en.yaml POST /v1/chat/completions
openapi: 3.1.0
info:
  title: Omniall AI — Gemini Chat image generation
  version: 1.2.0
  description: >
    Generate images with Gemini through a single OpenAI Chat Completions
    endpoint.


    **Path:** `POST https://api.omniall.ai/v1/chat/completions`


    Text-to-image, image-to-image, multi-image reference, and PDF / short-video
    reference

    are the **same API** with different `messages` payloads.


    Model examples: `gemini-nano-banana-2.1`, `gemini-3.1-flash-image-preview`,
    `gemini-3-pro-image-preview`.

    Use `extra_body.google.image_config` for `aspect_ratio` and `image_size`
    (`1K`/`2K`/`4K`).

    Optional Thinking (Banana 2.1):
    `extra_body.google.thinking_config.thinking_level` =

    `minimal` / `medium` (default) / `high`; `include_thoughts` only controls
    whether thought text is returned (snake_case).


    `messages[].content` part types:

    - plain string or `type: text` — prompt / edit instruction

    - `image_url` — reference image (HTTPS URL or data URL)

    - `file` — PDF (`file_data` HTTPS URL or `data:application/pdf;base64,...`;
    `filename` required)

    - `video_url` — short video (**string** HTTPS URL or
    `data:video/mp4;base64,...`)


    The gateway downloads remote URLs and converts them to Gemini `inlineData`.

    Auth: `Authorization: Bearer sk-...`
servers:
  - url: https://api.omniall.ai
security: []
paths:
  /v1/chat/completions:
    post:
      tags:
        - Gemini image
      summary: Chat image generation
      description: >
        Gemini image generation via OpenAI Chat Completions. Text-to-image and
        image-to-image share this endpoint.


        **Path:** `POST https://api.omniall.ai/v1/chat/completions`


        - **Text-to-image**: `content` as a plain string, or only `type: text`

        - **Image-to-image / multi-ref**: `content` array with `text` + one or
        more `image_url`

        - **PDF / short video** (Banana 2.1): add `type: file` / `type:
        video_url`


        Prefer non-streaming `stream: false`. Auth: `Authorization: Bearer
        sk-...`
      operationId: geminiChatImage
      parameters:
        - name: Authorization
          in: header
          required: true
          schema:
            type: string
            example: Bearer sk-...
          description: Bearer API key, e.g. `Bearer sk-...`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - model
                - messages
              description: Gemini Chat image request body (`POST /v1/chat/completions`).
              properties:
                model:
                  type: string
                  description: >-
                    Gemini image model id. Examples: `gemini-nano-banana-2.1`,
                    `gemini-3.1-flash-image-preview`.
                  example: gemini-3.1-flash-image-preview
                messages:
                  type: array
                  description: >-
                    Chat messages. Text-to-image is usually one `user` text;
                    image-to-image adds media parts.
                  items:
                    type: object
                    properties:
                      role:
                        type: string
                        description: Use `user` for image generation.
                        example: user
                      content:
                        oneOf:
                          - type: string
                            description: Plain-text prompt (text-to-image).
                          - type: array
                            description: >-
                              Multimodal parts — `text`, `image_url`, `file`
                              (PDF), `video_url`.
                            items:
                              type: object
                              properties:
                                type:
                                  type: string
                                  enum:
                                    - text
                                    - image_url
                                    - file
                                    - video_url
                                text:
                                  type: string
                                image_url:
                                  type: object
                                  properties:
                                    url:
                                      type: string
                                      description: >-
                                        HTTPS image URL or
                                        `data:image/...;base64,...`.
                                  required:
                                    - url
                                file:
                                  type: object
                                  description: >-
                                    PDF / document part. Both `filename` and
                                    `file_data` are required.
                                  properties:
                                    filename:
                                      type: string
                                      example: reference.pdf
                                    file_data:
                                      type: string
                                      description: >-
                                        HTTPS PDF URL or
                                        `data:application/pdf;base64,...`.
                                  required:
                                    - filename
                                    - file_data
                                video_url:
                                  type: string
                                  description: >-
                                    Video string — HTTPS URL or
                                    `data:video/mp4;base64,...`.
                    required:
                      - role
                      - content
                stream:
                  type: boolean
                  description: >-
                    Whether to stream. Prefer `false` for Chat image generation
                    (one-shot complete response).
                  default: false
                  example: false
                extra_body:
                  type: object
                  description: Provider extensions under `extra_body.google`.
                  properties:
                    google:
                      type: object
                      properties:
                        image_config:
                          type: object
                          description: >-
                            Output aspect ratio and resolution. camelCase
                            aliases also accepted.
                          properties:
                            aspect_ratio:
                              type: string
                              enum:
                                - '1:1'
                                - '2:3'
                                - '3:2'
                                - '3:4'
                                - '4:3'
                                - '4:5'
                                - '5:4'
                                - '9:16'
                                - '16:9'
                                - '21:9'
                              example: '1:1'
                            image_size:
                              type: string
                              enum:
                                - 1K
                                - 2K
                                - 4K
                              example: 2K
                        thinking_config:
                          type: object
                          description: >
                            Optional. Banana 2.1 Thinking (snake_case).

                            `thinking_level`: `minimal` / `medium` (default) /
                            `high`.
                          properties:
                            thinking_level:
                              type: string
                              enum:
                                - minimal
                                - medium
                                - high
                              example: high
                            include_thoughts:
                              type: boolean
                              example: false
            examples:
              Text-to-image:
                summary: Text-to-image (plain text)
                value:
                  model: gemini-3.1-flash-image-preview
                  messages:
                    - role: user
                      content: >-
                        An orange cat sleeping under cherry blossoms, Japanese
                        illustration, soft light
                  stream: false
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '1:1'
                        image_size: 2K
              Image-to-image:
                summary: Image-to-image (image URL)
                value:
                  model: gemini-3.1-flash-image-preview
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: >-
                            Generate three orthographic views of this object on
                            one canvas, pure white background
                        - type: image_url
                          image_url:
                            url: https://example.com/reference.jpg
                  stream: false
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '16:9'
                        image_size: 2K
              Multi-image reference:
                summary: Multi-image reference
                value:
                  model: gemini-3.1-flash-image-preview
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: >-
                            Using the style and layout of the following images,
                            generate a unified product poster
                        - type: image_url
                          image_url:
                            url: https://example.com/ref-style.jpg
                        - type: image_url
                          image_url:
                            url: https://example.com/ref-layout.jpg
                  stream: false
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '16:9'
                        image_size: 2K
              PDF URL reference:
                summary: PDF URL reference (Banana 2.1)
                value:
                  model: gemini-nano-banana-2.1
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: >-
                            Read the PDF. List labels, colors and shapes by
                            page, then generate a reference-sheet image on a
                            white background.
                        - type: file
                          file:
                            filename: reference.pdf
                            file_data: https://example.com/reference.pdf
                  stream: false
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '3:2'
                        image_size: 1K
              Short video reference:
                summary: Video URL reference (Banana 2.1)
                value:
                  model: gemini-nano-banana-2.1
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: >-
                            Watch the video. List scene elements in order, then
                            generate a reference-sheet image.
                        - type: video_url
                          video_url: https://example.com/clip.mp4
                  stream: false
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '3:2'
                        image_size: 1K
      responses:
        '200':
          description: Chat Completions response (SSE when streaming).
          content:
            application/json:
              schema:
                type: object
                additionalProperties: true
        '400':
          description: Invalid request
        '401':
          description: Unauthorized
        '429':
          description: Rate limited
        '500':
          description: Upstream/gateway error

````

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