POST
Non-streaming
This is Google’s unified generative API for developers: it uses a consistent input/output structure to cover text, multimodal, and tool-augmented scenarios.
https://api.poixe.com/v1beta/models/gemini-2.5-flash:generateContentPOST
Streaming
https://api.poixe.com/v1beta/models/gemini-2.5-flash:streamGenerateContent?alt=sseStreaming calls (SSE)
In Gemini, non-streaming and streaming are two different endpoints, and the request URL contains the model name (for example.../models/gemini-2.5-flash:xxx), rather than only specifying the model in the body as some protocols do.
- Non-streaming:
POST ...:generateContent - Streaming:
POST ...:streamGenerateContent?alt=sse
Authentication and request headers
Every request must carry an API key in the HTTP headers.Request parameters
The following are the most commonly used core request fields (covering single-turn text, multi-turn chat, and common sampling controls).The conversation content (or single-turn input). Gemini uses
contents[] to represent “conversation history + current turn input”.System instruction (optional). Used to hold developer/system-level constraints; it is also a
Content object (usually containing only text).The list of tools (optional). Used for capabilities such as function calling and code execution (support may vary by model and capability).
Tool configuration (optional). Used to specify the tool selection strategy, constraints, and so on (usually used together with
tools).Safety settings (optional). Used to override the default content safety thresholds (configured per category).
Response structure
A non-streaming request returns aGenerateContentResponse object; a streaming request returns multiple GenerateContentResponse chunks over SSE (you will continuously receive multiple data: {...} JSON lines).
Prompt safety feedback (if returned). When a prompt is filtered or blocked, you can usually find the reason here.
Token usage statistics (output field). We recommend interpreting and recording Gemini’s billing basis as follows:
input_tokens = promptTokenCount + toolUsePromptTokenCount,
output_tokens = candidatesTokenCount + thoughtsTokenCount,
total_tokens = input_tokens + output_tokens (usually matches totalTokenCount).Official docs: Text generation (Gemini API)
View Gemini’s text generation guide, examples, and best practices.