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

# NanoBanana OpenAI chat format

> Generate images via the OpenAI chat endpoint — ideal for the budget tier and OpenAI SDK users

## Models you can use

| Model ID         | Notes                                                          |
| ---------------- | -------------------------------------------------------------- |
| `nanobanana`     | Standard version                                               |
| `nanobanana_pro` | High-quality version                                           |
| `nanobanana_2`   | 2nd generation — **budget tier only, this format exclusively** |

## Image configuration

Pass Google extension parameters through the `extra_body` field:

```json
{
  "extra_body": {
    "google": {
      "image_config": {
        "aspect_ratio": "16:9",
        "image_size": "2K"
      }
    }
  }
}
```

## Response format

The image is embedded in `choices[0].message.content` as Markdown:

```
![image](data:image/jpeg;base64,/9j/4AAQ...)
```

## Relationship to the chat endpoint

The path `/v1/chat/completions` is shared with the chat completions
endpoint. This page specifically describes the image-generation
behavior and the unique `extra_body` parameters when `model` is a
NanoBanana ID.


## OpenAPI

````yaml /openapi/images.en.yaml post /v1/chat/completions
openapi: 3.1.0
info:
  title: InfinityBlue API — Images
  version: 1.0.0
  summary: Image generation and editing endpoints
  description: >
    InfinityBlue image endpoints support both the OpenAI native format and the

    NanoBanana (Gemini native) format, covering text-to-image generation,

    image editing, and multi-reference image fusion.


    ## 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/images/*` | OpenAI Images API |

    | `/v1/chat/completions` | OpenAI Chat Completions (NanoBanana OpenAI
    format) |

    | `/v1beta/models/{model}:generateContent` | Google Gemini native
    (NanoBanana native format) |
  contact:
    name: InfinityBlue
    url: https://getinfinityblue.com
servers:
  - url: https://api.getinfinityblue.com
    description: Production
security:
  - bearerAuth: []
tags:
  - name: Images
    description: |
      OpenAI-compatible image generation and editing endpoints supporting
      models such as `gpt-image-2`.
  - name: NanoBanana
    description: |
      NanoBanana image generation endpoints available in both Gemini native
      format and OpenAI chat format, supporting text-to-image, multi-reference
      fusion, and style-unification workflows.
paths:
  /v1/chat/completions:
    post:
      tags:
        - NanoBanana
      summary: NanoBanana image generation (OpenAI chat format)
      description: >
        Generate images using NanoBanana models via the OpenAI Chat Completions

        format. Ideal for users already using the OpenAI SDK, or when using the

        `nanobanana_2` budget-tier model — which **only supports this format**

        and cannot be used with the Gemini native endpoint.


        The generated image is embedded in the response message's `content`

        field as a Markdown inline image:

        `![image](data:image/jpeg;base64,<base64data>)`


        Configure aspect ratio and resolution via
        `extra_body.google.image_config`.


        > **Note**: This endpoint shares the path `/v1/chat/completions` with

        > the chat completions endpoint. InfinityBlue automatically routes the

        > request to the image-generation backend when a NanoBanana model ID is

        > passed in `model`. In the Mintlify documentation, this page is

        > rendered as a standalone image generation page; if you integrate with

        > doc build tooling, confirm that path reuse does not cause operationId

        > conflicts.
      operationId: createNanoBananaImageViaChat
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NanoBananaChatRequest'
            examples:
              basic:
                summary: Basic text-to-image
                value:
                  model: nanobanana_pro
                  stream: false
                  messages:
                    - role: user
                      content: Draw a cat sitting on a rooftop under moonlight
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '16:9'
                        image_size: 2K
              nanobanana2_budget:
                summary: NanoBanana 2 (budget tier)
                value:
                  model: nanobanana_2
                  stream: false
                  messages:
                    - role: user
                      content: >-
                        A panda sitting in a bamboo forest eating bamboo,
                        watercolor style
                  extra_body:
                    google:
                      image_config:
                        aspect_ratio: '1:1'
                        image_size: 1K
      responses:
        '200':
          description: Image generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NanoBananaChatResponse'
        '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:
    NanoBananaChatRequest:
      type: object
      required:
        - model
        - messages
      description: NanoBanana OpenAI chat-format image generation request body.
      properties:
        model:
          type: string
          description: |
            NanoBanana model ID. Options: `nanobanana`, `nanobanana_pro`,
            `nanobanana_2`. The budget-tier `nanobanana_2` only supports this
            format and cannot be used with the Gemini native endpoint.
          examples:
            - nanobanana_pro
            - nanobanana_2
        stream:
          type: boolean
          default: false
          description: Whether to stream the response. Set to `false` for image generation.
        messages:
          type: array
          description: Conversation messages containing the image generation prompt.
          items:
            type: object
            required:
              - role
              - content
            properties:
              role:
                type: string
                description: The role of the message author.
                enum:
                  - user
                  - system
                  - assistant
              content:
                type: string
                description: >-
                  Message content — for image generation, this is the text
                  prompt.
        extra_body:
          type: object
          description: |
            Extension parameters. Pass image configuration (aspect ratio and
            resolution) via `google.image_config`.
          properties:
            google:
              type: object
              description: Google extension parameters.
              properties:
                image_config:
                  type: object
                  description: Image generation configuration.
                  required:
                    - aspect_ratio
                    - image_size
                  properties:
                    aspect_ratio:
                      type: string
                      description: |
                        Output image aspect ratio. Options: `1:1`, `3:4`,
                        `4:3`, `9:16`, `16:9`.
                      examples:
                        - '16:9'
                    image_size:
                      type: string
                      description: >
                        Output image resolution level. Options: `1K`, `2K`,
                        `4K`.
                      examples:
                        - 2K
    NanoBananaChatResponse:
      type: object
      description: >-
        NanoBanana OpenAI chat-format response body. The image is embedded in
        the message content as a Markdown inline image.
      properties:
        id:
          type: string
          description: Unique identifier for this request.
          examples:
            - chatcmpl-20251211160744809365000fdOhL0KY
        model:
          type: string
          description: The model that processed the request.
          examples:
            - nanobanana_pro
        object:
          type: string
          description: Object type.
          examples:
            - chat.completion
        created:
          type: integer
          description: Unix timestamp (seconds) of creation.
          examples:
            - 1765440499
        choices:
          type: array
          description: List of generated results.
          items:
            type: object
            properties:
              index:
                type: integer
                description: Zero-based index of this result.
              message:
                type: object
                description: >-
                  The generated message. The `content` field contains the
                  Markdown inline image.
                properties:
                  role:
                    type: string
                    examples:
                      - assistant
                  content:
                    type: string
                    description: |
                      Message content. The image is embedded as a Markdown
                      inline image:
                      `![image](data:image/jpeg;base64,<base64data>)`
                    examples:
                      - '![image](data:image/jpeg;base64,/9j/4AAQ...)'
              finish_reason:
                type: string
                description: The reason generation stopped.
                examples:
                  - stop
        usage:
          type: object
          description: Token usage statistics.
          properties:
            prompt_tokens:
              type: integer
              description: Tokens consumed by the prompt.
            completion_tokens:
              type: integer
              description: >-
                Tokens consumed by the completion (including image generation
                tokens).
            total_tokens:
              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 size. Supported sizes are 1024x1024, 1536x1024,
                  1024x1536.
            type:
              type: string
              description: Error type.
              examples:
                - invalid_request_error
            param:
              type:
                - string
                - 'null'
              description: The parameter related to the error.
              examples:
                - size
            code:
              type:
                - string
                - 'null'
              description: Error code.
              examples:
                - invalid_size
  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).

````