Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Googleapis Python genai ContentDelta Types

From Leeroopedia
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

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)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment