OpenAI chat format (Chat Completions + Gemini image)
Standard OpenAI Chat Completions, with chat-style prompts driving Gemini image generation.Basics
- Endpoint:
POST /v1/chat/completions - Auth:
Bearer Token - Content-Type:
application/json
Request body
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | e.g. gemini-3-pro-image-preview. |
| messages | array | Yes | Chat messages. |
| └─ role | string | Yes | user, assistant, system. |
| └─ content | string | Yes | Prompt, e.g. “draw a cat”. |
| stream | boolean | Yes | Streaming; use false for image generation. |
| extra_body | object | No | Vendor extensions. |
object | No | Google-specific block. | |
| └─ └─ image_config | object | No | Image settings. |
| └─ └─ └─ aspect_ratio | string | No | e.g. 16:9, 1:1. |
| └─ └─ └─ image_size | string | No | e.g. 2K, 4K. |
Response
200 OK| Field | Type | Description |
|---|---|---|
| id | string | Request id. |
| object | string | chat.completion. |
| choices | array | Results. |
| └─ message | object | role + content (image often as Markdown + base64). |
| └─ finish_reason | string | e.g. stop. |
| usage | object | Token usage. |
Request example
Response example
Tips
- Extracting images:
contentoften embeds—parse the data URI for display. - extra_body: Standard OpenAI SDK extension slot for vendor options without breaking the protocol.
- Mock: For local tests,
http://127.0.0.1:4523/mock/7707339.

