<string>{}API reference
Gemini streamGenerateContent
Native SSE text and function calls.
<string>{}POST /v1beta/models/{model}:streamGenerateContent?alt=sse
Send the gateway token in x-goog-api-key and select SSE with alt=sse. The request shape matches nonstreaming generateContent, but uses a different path action; a Chat-style stream body field is not a substitute.
Each SSE data payload contains a Gemini response. Text and function calls appear in candidate content parts. Check prompt feedback, candidate indices, and the final finish reason; EOF alone is insufficient. Declare tools through tools[].functionDeclarations and return results as functionResponse.
The complete Python SSE and tool-loop example covers both run modes, signature preservation, optional ID association, and failures. This schema expands common fields only, without guaranteeing Live API, fine-grained argument extensions, or support on every channel.
阅读中文
Media content parts
Nativecontents[].parts[] can contain inlineData: {mimeType, data} or fileData: {mimeType, fileUri}; inline data is plain Base64. The target upstream must support the format and source. videoMetadata and mediaResolution are conditional native extensions, not a universal gateway transcoding or frame-extraction service.
Media input does not change the response protocol or completion checks. The audited gateway scope provides no Gemini Files upload/management or Interactions endpoints; SDK auto-upload introduces extra unsupported requests. Start with the complete non-streaming video example; streamed output still follows this endpoint’s SSE events.
Built-in metadata in SSE
The request accepts the same conditional nativegoogleSearch, urlContext, and codeExecution tool fields. Native SSE forwards upstream JSON events. Retain candidate metadata and code/result parts across events; do not flatten all events into plain text or assume each event contains a complete grounding record. The existing text/function SSE sample does not implement these built-in consumers. Start with the non-streaming built-in example; native byte offsets and source association need protocol-aware accumulation before adding streaming.Authorizations
GeminiApiKeyBearerAuth
网关令牌 / Gateway token
Path Parameters
裸模型 ID,不含 models/ 和动作后缀 / Bare model ID without models/ or an action suffix.
Example:
"YOUR_MODEL_ID"
Query Parameters
选择 SSE 传输 / Select SSE transport.
Available options:
sse Body
application/json
Response
检查候选结束状态并处理流内错误 / Validate candidate finish status and in-stream errors.
The response is of type string.