Call Gemini 2.x and 3.x models through a unified endpoint with text, image input, and thinking support.
POST /v1/chat/completions
Auth: {'type': 'bearer', 'prefix': 'sk-', 'description': 'Pass your API key in the `Authorization: Bearer sk-xxx` header.'}
The Gemini model is fully compatible with the OpenAI Chat Completions protocol. This page demonstrates Gemini's unique capabilities: - **Multimodal content array**: `content` can be `[{type:"text",text:...},{type:"image_url",image_url:{url:...}}]` - **Thinking / Reasoning**: 2.5 Pro / 3.1 Pro Preview enables deep reasoning via `reasoning_effort: "low"|"medium"|"high"` - **Long context**: 2.5 Pro supports 200K tokens, Flash 128K + - **Structured output**: `response_format: {type:"json_object"}` or pass `response_mime_type`
model | string | required | Gemini model ID, e.g. `gemini-2.5-pro` / `gemini-2.5-flash` / `gemini-2.5-flash-lite` / `gemini-3.1-pro-preview` / `gemini-3.1-flash-lite-preview` |
messages | array | required | Array of multimodal messages. `content` can be a string or a mixed array |
role | string | required | |
content | string | required | Text string, or array of content blocks `[{"type":"text","text":"..."},{"type":"image_url","image_url":{"url":"https://..."}}]` |
temperature | number | ||
top_p | number | ||
top_k | integer | (Gemini-specific) Top-K sampling, recommended not to use with top_p simultaneously | |
max_tokens | integer | ||
stream | boolean | ||
reasoning_effort | string | (Only available in 2.5 Pro / 3.1 Pro Preview) Thinking depth, high for better accuracy but slower | |
response_format | object | If `{"type":"json_object"}` forces JSON output | |
stop | array |
200 — Gemini-generated result (OpenAI format)curl https://api.router.ai/v1/chat/completions \
-H "Authorization: Bearer sk-xxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-pro",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "这张图里是什么?"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.jpg"}}
]
}
],
"reasoning_effort": "medium"
}'