Implementation:Googleapis Python genai ContentDelta Types
| Knowledge Sources | |
|---|---|
| Domains | Streaming, Type_System |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
Concrete type definitions for content deltas in streaming Interactions API responses.
Description
The content_delta module defines the ContentDelta model and all its delta sub-types for SSE streaming. The Delta discriminated union covers text, image, audio, video, document, function call/result, code execution, Google Search, URL context, MCP tool, and file search deltas, each with type-specific fields.
Usage
These types are returned as events when streaming Interactions API responses. They represent incremental content updates during generation.
Code Reference
Source Location
- Repository: Googleapis_Python_genai
- File: google/genai/_interactions/types/content_delta.py
- Lines: 1-350
Signature
class ContentDelta(BaseModel):
delta: Optional[Delta] = None
event_id: Optional[str] = None
event_type: Optional[str] = None
index: Optional[int] = None
# Delta is a discriminated union of:
# DeltaTextDelta, DeltaImageDelta, DeltaAudioDelta,
# DeltaDocumentDelta, DeltaVideoDelta, DeltaThoughtSummaryDelta,
# DeltaFunctionCallDelta, DeltaFunctionResultDelta,
# DeltaCodeExecutionCallDelta, DeltaCodeExecutionResultDelta,
# DeltaURLContextCallDelta, DeltaGoogleSearchCallDelta,
# DeltaMCPServerToolCallDelta, DeltaFileSearchCallDelta, etc.
Import
from google.genai._interactions.types.content_delta import ContentDelta
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| (constructed from JSON) | dict | Yes | SSE event data from streaming response |
Outputs
| Name | Type | Description |
|---|---|---|
| delta | Delta (union) | Content update with type-specific fields (text, image, audio, etc.) |
| event_id | str | Event identifier |
| event_type | str | Delta type discriminator |
| index | int | Content index within turn |
Usage Examples
from google.genai._interactions.types.content_delta import ContentDelta, DeltaTextDelta
# ContentDelta objects are received during streaming
# Example: handling a text delta
delta = ContentDelta(
delta=DeltaTextDelta(type="text", text="Hello "),
event_type="content_delta",
index=0,
)
if isinstance(delta.delta, DeltaTextDelta):
print(delta.delta.text)