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

# Gemini OpenAI-Compatible Format

> Production-revalidated Gemini 3 Pro via /v1/chat/completions

> Last updated: 2026-06-06

# Gemini OpenAI-Compatible Format

You can call Gemini through the OpenAI Chat Completions compatible route.

```
POST /v1/chat/completions
```

This page only documents compatibility-layer behavior that was revalidated against Crazyrouter production on `2026-03-22`.

Current primary example model:

* `gemini-3.1-pro`

## Current conclusion

This production recheck confirmed that:

* `gemini-3.1-pro` works through `/v1/chat/completions` for normal text chat
* streaming returns standard `chat.completion.chunk` SSE objects
* for Gemini-specific capabilities such as structured outputs, Google Search, and thinking, you should still prefer [Gemini Native Format](/en/chat/gemini/native)

***

## Basic conversation

```bash cURL theme={null}
curl https://api.crazyrouter.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gemini-3.1-pro",
    "messages": [
      {
        "role": "system",
        "content": "You are a concise assistant."
      },
      {
        "role": "user",
        "content": "Explain quantum entanglement in one sentence."
      }
    ],
    "max_tokens": 128
  }'
```

Verified response shape:

```json theme={null}
{
  "object": "chat.completion",
  "model": "gemini-3.1-pro",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "..."
      }
    }
  ]
}
```

***

## Python example

```python Python theme={null}
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://api.crazyrouter.com/v1"
)

response = client.chat.completions.create(
    model="gemini-3.1-pro",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Explain quantum entanglement in one sentence."}
    ],
    max_tokens=128
)

print(response.choices[0].message.content)
```

***

## Streaming output

This production recheck also confirmed streaming compatibility:

```python Python theme={null}
stream = client.chat.completions.create(
    model="gemini-3.1-pro",
    messages=[
        {"role": "user", "content": "Write one short sentence about AI."}
    ],
    max_tokens=64,
    stream=True
)

for chunk in stream:
    delta = chunk.choices[0].delta
    if delta.content is not None:
        print(delta.content, end="")
```

Observed SSE shape:

```text theme={null}
data: {"object":"chat.completion.chunk","model":"gemini-3.1-pro",...}
data: {"choices":[{"delta":{"content":"..."}}],...}
data: [DONE]
```

***

## When to use compatible vs native

* If you already have OpenAI SDK code and only need standard chat, use the compatible route
* If you need Gemini-native structured outputs, Google Search, thinking, or native metadata, use [Gemini Native Format](/en/chat/gemini/native)

<Note>
  This page still only covers the `/v1/chat/completions` compatibility layer and does not fold Gemini-backed image behavior into it. For image workloads, do not keep documenting the Nano Banana family as a stable `/v1/images/generations` contract.
  The currently preferred entry point is [Nano Banana 2](/en/images/nano-banana-2), which now points to native Gemini `POST /v1beta/models/nano-banana-2:generateContent`.
  [Nano Banana](/en/images/nano-banana) remains controlled-testing only.
</Note>
