strands.types.content
¶
Content-related type definitions for the SDK.
This module defines the types used to represent messages, content blocks, and other content-related structures in the SDK. These types are modeled after the Bedrock API.
- Bedrock docs: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_Types_Amazon_Bedrock_Runtime.html
Messages = List[Message]
module-attribute
¶
A list of messages representing a conversation.
Role = Literal['user', 'assistant']
module-attribute
¶
Role of a message sender.
- "user": Messages from the user to the assistant
- "assistant": Messages from the assistant to the user
CachePoint
¶
Bases: TypedDict
A cache point configuration for optimizing conversation history.
Attributes:
| Name | Type | Description |
|---|---|---|
type |
str
|
The type of cache point, typically "default". |
Source code in strands/types/content.py
64 65 66 67 68 69 70 71 | |
CitationsContentBlock
¶
Bases: TypedDict
A content block containing generated text and associated citations.
This block type is returned when document citations are enabled, providing traceability between the generated content and the source documents that informed the response.
Attributes:
| Name | Type | Description |
|---|---|---|
citations |
List[Citation]
|
An array of citations that reference the source documents used to generate the associated content. |
content |
List[CitationGeneratedContent]
|
The generated content that is supported by the associated citations. |
Source code in strands/types/citations.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
ContentBlock
¶
Bases: TypedDict
A block of content for a message that you pass to, or receive from, a model.
Attributes:
| Name | Type | Description |
|---|---|---|
cachePoint |
CachePoint
|
A cache point configuration to optimize conversation history. |
document |
DocumentContent
|
A document to include in the message. |
guardContent |
GuardContent
|
Contains the content to assess with the guardrail. |
image |
ImageContent
|
Image to include in the message. |
reasoningContent |
ReasoningContentBlock
|
Contains content regarding the reasoning that is carried out by the model. |
text |
str
|
Text to include in the message. |
toolResult |
ToolResult
|
The result for a tool request that a model makes. |
toolUse |
ToolUse
|
Information about a tool use request from a model. |
video |
VideoContent
|
Video to include in the message. |
citationsContent |
CitationsContentBlock
|
Contains the citations for a document. |
Source code in strands/types/content.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 | |
ContentBlockDelta
¶
Bases: TypedDict
The content block delta event.
Attributes:
| Name | Type | Description |
|---|---|---|
contentBlockIndex |
int
|
The block index for a content block delta event. |
delta |
DeltaContent
|
The delta for a content block delta event. |
Source code in strands/types/content.py
148 149 150 151 152 153 154 155 156 157 | |
ContentBlockStart
¶
Bases: TypedDict
Content block start information.
Attributes:
| Name | Type | Description |
|---|---|---|
toolUse |
Optional[ContentBlockStartToolUse]
|
Information about a tool that the model is requesting to use. |
Source code in strands/types/content.py
138 139 140 141 142 143 144 145 | |
ContentBlockStartToolUse
¶
Bases: TypedDict
The start of a tool use block.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The name of the tool that the model is requesting to use. |
toolUseId |
str
|
The ID for the tool request. |
Source code in strands/types/content.py
126 127 128 129 130 131 132 133 134 135 | |
ContentBlockStop
¶
Bases: TypedDict
A content block stop event.
Attributes:
| Name | Type | Description |
|---|---|---|
contentBlockIndex |
int
|
The index for a content block. |
Source code in strands/types/content.py
160 161 162 163 164 165 166 167 | |
DeltaContent
¶
Bases: TypedDict
A block of content in a streaming response.
Attributes:
| Name | Type | Description |
|---|---|---|
text |
str
|
The content text. |
toolUse |
Dict[Literal['input'], str]
|
Information about a tool that the model is requesting to use. |
Source code in strands/types/content.py
114 115 116 117 118 119 120 121 122 123 | |
DocumentContent
¶
Bases: TypedDict
A document to include in a message.
Attributes:
| Name | Type | Description |
|---|---|---|
format |
Literal['pdf', 'csv', 'doc', 'docx', 'xls', 'xlsx', 'html', 'txt', 'md']
|
The format of the document (e.g., "pdf", "txt"). |
name |
str
|
The name of the document. |
source |
DocumentSource
|
The source containing the document's binary content. |
Source code in strands/types/media.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 | |
GuardContent
¶
Bases: TypedDict
Content block to be evaluated by guardrails.
Attributes:
| Name | Type | Description |
|---|---|---|
text |
GuardContentText
|
Text within content block to be evaluated by the guardrail. |
Source code in strands/types/content.py
30 31 32 33 34 35 36 37 | |
GuardContentText
¶
Bases: TypedDict
Text content to be evaluated by guardrails.
Attributes:
| Name | Type | Description |
|---|---|---|
qualifiers |
List[Literal['grounding_source', 'query', 'guard_content']]
|
The qualifiers describing the text block. |
text |
str
|
The input text details to be evaluated by the guardrail. |
Source code in strands/types/content.py
18 19 20 21 22 23 24 25 26 27 | |
ImageContent
¶
Bases: TypedDict
An image to include in a message.
Attributes:
| Name | Type | Description |
|---|---|---|
format |
ImageFormat
|
The format of the image (e.g., "png", "jpeg"). |
source |
ImageSource
|
The source containing the image's binary content. |
Source code in strands/types/media.py
58 59 60 61 62 63 64 65 66 67 | |
Message
¶
Bases: TypedDict
A message in a conversation with the agent.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
List[ContentBlock]
|
The message content. |
role |
Role
|
The role of the message sender. |
Source code in strands/types/content.py
178 179 180 181 182 183 184 185 186 187 | |
ReasoningContentBlock
¶
Bases: TypedDict
Contains content regarding the reasoning that is carried out by the model.
Attributes:
| Name | Type | Description |
|---|---|---|
reasoningText |
ReasoningTextBlock
|
The reasoning that the model used to return the output. |
redactedContent |
bytes
|
The content in the reasoning that was encrypted by the model provider for safety reasons. |
Source code in strands/types/content.py
52 53 54 55 56 57 58 59 60 61 | |
ReasoningTextBlock
¶
Bases: TypedDict
Contains the reasoning that the model used to return the output.
Attributes:
| Name | Type | Description |
|---|---|---|
signature |
Optional[str]
|
A token that verifies that the reasoning text was generated by the model. |
text |
str
|
The reasoning that the model used to return the output. |
Source code in strands/types/content.py
40 41 42 43 44 45 46 47 48 49 | |
SystemContentBlock
¶
Bases: TypedDict
Contains configurations for instructions to provide the model for how to handle input.
Attributes:
| Name | Type | Description |
|---|---|---|
cachePoint |
CachePoint
|
A cache point configuration to optimize conversation history. |
text |
str
|
A system prompt for the model. |
Source code in strands/types/content.py
102 103 104 105 106 107 108 109 110 111 | |
ToolResult
¶
Bases: TypedDict
Result of a tool execution.
Attributes:
| Name | Type | Description |
|---|---|---|
content |
list[ToolResultContent]
|
List of result content returned by the tool. |
status |
ToolResultStatus
|
The status of the tool execution ("success" or "error"). |
toolUseId |
str
|
The unique identifier of the tool use request that produced this result. |
Source code in strands/types/tools.py
87 88 89 90 91 92 93 94 95 96 97 98 | |
ToolUse
¶
Bases: TypedDict
A request from the model to use a specific tool with the provided input.
Attributes:
| Name | Type | Description |
|---|---|---|
input |
Any
|
The input parameters for the tool. Can be any JSON-serializable type. |
name |
str
|
The name of the tool to invoke. |
toolUseId |
str
|
A unique identifier for this specific tool use request. |
Source code in strands/types/tools.py
52 53 54 55 56 57 58 59 60 61 62 63 64 | |
VideoContent
¶
Bases: TypedDict
A video to include in a message.
Attributes:
| Name | Type | Description |
|---|---|---|
format |
VideoFormat
|
The format of the video (e.g., "mp4", "avi"). |
source |
VideoSource
|
The source containing the video's binary content. |
Source code in strands/types/media.py
84 85 86 87 88 89 90 91 92 93 | |