Skip to main content
POST

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

PDF URL (complete)

Video URL (complete)

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):
include_thoughts only controls whether thought text is returned; you can omit thinking_config for typical use. See Overview · Thinking.

Headers

Authorization
string
required

Bearer API key, e.g. Bearer sk-....

Example:

"Bearer sk-..."

Body

application/json

Gemini Chat image request body (POST /v1/chat/completions).

model
string
required

Gemini image model id. Examples: gemini-nano-banana-2.1, gemini-3.1-flash-image-preview.

Example:

"gemini-3.1-flash-image-preview"

messages
object[]
required

Chat messages. Text-to-image is usually one user text; image-to-image adds media parts.

stream
boolean
default:false

Whether to stream. Prefer false for Chat image generation (one-shot complete response).

Example:

false

extra_body
object

Provider extensions under extra_body.google.

Response

Chat Completions response (SSE when streaming).

The response is of type object.