Gemini chat and multimodal input

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`

Request body

modelstringrequiredGemini 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`
messagesarrayrequiredArray of multimodal messages. `content` can be a string or a mixed array
    rolestringrequired
    contentstringrequiredText string, or array of content blocks `[{"type":"text","text":"..."},{"type":"image_url","image_url":{"url":"https://..."}}]`
temperaturenumber
top_pnumber
top_kinteger(Gemini-specific) Top-K sampling, recommended not to use with top_p simultaneously
max_tokensinteger
streamboolean
reasoning_effortstring(Only available in 2.5 Pro / 3.1 Pro Preview) Thinking depth, high for better accuracy but slower
response_formatobjectIf `{"type":"json_object"}` forces JSON output
stoparray

Responses

Example

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"
  }'

API reference