Skip to main content
POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://api.getinfinityblue.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "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"
      }
    }
  }
}
'
{
  "id": "<string>",
  "model": "<string>",
  "object": "<string>",
  "created": 123,
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "<string>",
        "content": "<string>"
      },
      "finish_reason": "<string>"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

Models you can use

Model IDNotes
nanobananaStandard version
nanobanana_proHigh-quality version
nanobanana_22nd generation — budget tier only, this format exclusively

Image configuration

Pass Google extension parameters through the extra_body field:
{
  "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.

Authorizations

Authorization
string
header
required

Bearer token authentication, format: Authorization: Bearer sk-xxxxxx. Get your API key in the console.

Body

application/json

NanoBanana OpenAI chat-format image generation request body.

model
string
required

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"

messages
object[]
required

Conversation messages containing the image generation prompt.

stream
boolean
default:false

Whether to stream the response. Set to false for image generation.

extra_body
object

Extension parameters. Pass image configuration (aspect ratio and resolution) via google.image_config.

Response

Image generated successfully

NanoBanana OpenAI chat-format response body. The image is embedded in the message content as a Markdown inline image.

id
string

Unique identifier for this request.

Example:

"chatcmpl-20251211160744809365000fdOhL0KY"

model
string

The model that processed the request.

Example:

"nanobanana_pro"

object
string

Object type.

Example:

"chat.completion"

created
integer

Unix timestamp (seconds) of creation.

Example:

1765440499

choices
object[]

List of generated results.

usage
object

Token usage statistics.