Skip to content

strands.types.streaming

Streaming-related type definitions for the SDK.

These types are modeled after the Bedrock API.

class MessageStartEvent(TypedDict)

Defined in: src/strands/types/streaming.py:16

Event signaling the start of a message in a streaming response.

Attributes:

  • role - The role of the message sender (e.g., “assistant”, “user”).
class ContentBlockStartEvent(TypedDict)

Defined in: src/strands/types/streaming.py:26

Event signaling the start of a content block in a streaming response.

Attributes:

  • contentBlockIndex - Index of the content block within the message. This is optional to accommodate different model providers.
  • start - Information about the content block being started.
class ContentBlockDeltaText(TypedDict)

Defined in: src/strands/types/streaming.py:39

Text content delta in a streaming response.

Attributes:

  • text - The text fragment being streamed.
class ContentBlockDeltaToolUse(TypedDict)

Defined in: src/strands/types/streaming.py:49

Tool use input delta in a streaming response.

Attributes:

  • input - The tool input fragment being streamed.
class CitationSourceContentDelta(TypedDict)

Defined in: src/strands/types/streaming.py:59

Contains incremental updates to source content text during streaming.

Allows clients to build up the cited content progressively during streaming responses.

Attributes:

  • text - An incremental update to the text content from the source document that is being cited.
class CitationsDelta(TypedDict)

Defined in: src/strands/types/streaming.py:73

Contains incremental updates to citation information during streaming.

This allows clients to build up citation data progressively as the response is generated.

Attributes:

  • location - Specifies the precise location within a source document where cited content can be found. This can include character-level positions, page numbers, or document chunks depending on the document type and indexing method.
  • sourceContent - The specific content from the source document that was referenced or cited in the generated response.
  • title - The title or identifier of the source document being cited.
class ReasoningContentBlockDelta(TypedDict)

Defined in: src/strands/types/streaming.py:94

Delta for reasoning content block in a streaming response.

Attributes:

  • redactedContent - The content in the reasoning that was encrypted by the model provider for safety reasons.
  • signature - A token that verifies that the reasoning text was generated by the model.
  • text - The reasoning that the model used to return the output.
class ContentBlockDelta(TypedDict)

Defined in: src/strands/types/streaming.py:108

A block of content in a streaming response.

Attributes:

  • reasoningContent - Contains content regarding the reasoning that is carried out by the model.
  • text - Text fragment being streamed.
  • toolUse - Tool use input fragment being streamed.
class ContentBlockDeltaEvent(TypedDict)

Defined in: src/strands/types/streaming.py:123

Event containing a delta update for a content block in a streaming response.

Attributes:

  • contentBlockIndex - Index of the content block within the message. This is optional to accommodate different model providers.
  • delta - The incremental content update for the content block.
class ContentBlockStopEvent(TypedDict)

Defined in: src/strands/types/streaming.py:136

Event signaling the end of a content block in a streaming response.

Attributes:

  • contentBlockIndex - Index of the content block within the message. This is optional to accommodate different model providers.
class MessageStopEvent(TypedDict)

Defined in: src/strands/types/streaming.py:147

Event signaling the end of a message in a streaming response.

Attributes:

  • additionalModelResponseFields - Additional fields to include in model response.
  • stopReason - The reason why the model stopped generating content.
class MetadataEvent(TypedDict)

Defined in: src/strands/types/streaming.py:159

Event containing metadata about the streaming response.

Attributes:

  • metrics - Performance metrics related to the model invocation.
  • trace - Trace information for debugging and monitoring.
  • usage - Resource usage information for the model invocation.
class ExceptionEvent(TypedDict)

Defined in: src/strands/types/streaming.py:173

Base event for exceptions in a streaming response.

Attributes:

  • message - The error message describing what went wrong.
class ModelStreamErrorEvent(ExceptionEvent)

Defined in: src/strands/types/streaming.py:183

Event for model streaming errors.

Attributes:

  • originalMessage - The original error message from the model provider.
  • originalStatusCode - The HTTP status code returned by the model provider.
class RedactContentEvent(TypedDict)

Defined in: src/strands/types/streaming.py:195

Event for redacting content.

Attributes:

  • redactUserContentMessage - The string to overwrite the users input with.
  • redactAssistantContentMessage - The string to overwrite the assistants output with.
class StreamEvent(TypedDict)

Defined in: src/strands/types/streaming.py:208

The messages output stream.

Attributes:

  • contentBlockDelta - Delta content for a content block.
  • contentBlockStart - Start of a content block.
  • contentBlockStop - End of a content block.
  • internalServerException - Internal server error information.
  • messageStart - Start of a message.
  • messageStop - End of a message.
  • metadata - Metadata about the streaming response.
  • modelStreamErrorException - Model streaming error information.
  • serviceUnavailableException - Service unavailable error information.
  • throttlingException - Throttling error information.
  • validationException - Validation error information.