Gemini 3.1 Pro is Google DeepMind’s flagship multimodal model with strong reasoning capabilities, seamless understanding of text, images, video, and audio, plus large-scale long-context support.
stream: true is set in the request, the API returns responses as server-sent events (SSE) with Content-Type: text/event-stream. This allows for progressive response delivery, where message deltas are sent incrementally as they are generated. Each event contains partial message content, enabling real-time display of responses in your application.
Streaming Response Format:
text/event-streamdata: followed by JSONfinish_reasontools parameter:
All APIs require authentication via Bearer Token.
Get API Key:
Usage: Add to request header: Authorization: Bearer YOUR_API_KEY
Note:
Array of message objects. Each message has a role and content.
Unified Media File Format:
In the content array, whether it's images, videos, audio, or other document types, all media files use the same format structure:
type field is always "image_url"image_url field name remains unchangedurl value, which points to the corresponding media file addressFor example: images, videos, audio, PDFs, and other documents all use the same { type: 'image_url', image_url: { url: '...' } } structure.
1If set to true, partial message deltas will be sent as server-sent events. Defaults to true.
Optional array of tools the model can call. For Google Search grounding, use: [{"type": "function", "function": {"name": "googleSearch"}}] - This enables real-time information retrieval via Google Search. When you need up-to-date information, news, or current events, include this tool in your request.
Whether to include thinking process. If set to true, thoughts will be included in the response; otherwise they will not appear. Defaults to true.
Reasoning effort. Low effort responds faster, high effort responds slower but solves more complex problems. Defaults to "high".
low, high Request successful. Returns standard chat completion format.
Unique identifier for the chat completion
"chatcmpl-example-123"
Object type
"chat.completion"
Unix timestamp when the completion was created
1677652288
Model name
"gemini-3.1-pro"
Array of completion choices