Skip to content

strands.types.media

Media-related type definitions for 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

DocumentFormat = Literal['pdf', 'csv', 'doc', 'docx', 'xls', 'xlsx', 'html', 'txt', 'md'] module-attribute

Supported document formats.

ImageFormat = Literal['png', 'jpeg', 'gif', 'webp'] module-attribute

Supported image formats.

SourceLocation = Location | S3Location module-attribute

VideoFormat = Literal['flv', 'mkv', 'mov', 'mpeg', 'mpg', 'mp4', 'three_gp', 'webm', 'wmv'] module-attribute

Supported video formats.

CitationsConfig

Bases: TypedDict

Configuration for enabling citations on documents.

Attributes:

Name Type Description
enabled bool

Whether citations are enabled for this document.

Source code in strands/types/citations.py
11
12
13
14
15
16
17
18
class CitationsConfig(TypedDict):
    """Configuration for enabling citations on documents.

    Attributes:
        enabled: Whether citations are enabled for this document.
    """

    enabled: bool

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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
class DocumentContent(TypedDict, total=False):
    """A document to include in a message.

    Attributes:
        format: The format of the document (e.g., "pdf", "txt").
        name: The name of the document.
        source: The source containing the document's binary content.
    """

    format: Literal["pdf", "csv", "doc", "docx", "xls", "xlsx", "html", "txt", "md"]
    name: str
    source: DocumentSource
    citations: CitationsConfig | None
    context: str | None

DocumentSource

Bases: TypedDict

Contains the content of a document.

Only one of bytes or s3Location should be specified.

Attributes:

Name Type Description
bytes bytes

The binary content of the document.

location SourceLocation

Location of the document.

Source code in strands/types/media.py
50
51
52
53
54
55
56
57
58
59
60
61
class DocumentSource(TypedDict, total=False):
    """Contains the content of a document.

    Only one of `bytes` or `s3Location` should be specified.

    Attributes:
        bytes: The binary content of the document.
        location: Location of the document.
    """

    bytes: bytes
    location: SourceLocation

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
 98
 99
100
101
102
103
104
105
106
107
class ImageContent(TypedDict):
    """An image to include in a message.

    Attributes:
        format: The format of the image (e.g., "png", "jpeg").
        source: The source containing the image's binary content.
    """

    format: ImageFormat
    source: ImageSource

ImageSource

Bases: TypedDict

Contains the content of an image.

Only one of bytes or s3Location should be specified.

Attributes:

Name Type Description
bytes bytes

The binary content of the image.

location SourceLocation

Location of the image.

Source code in strands/types/media.py
84
85
86
87
88
89
90
91
92
93
94
95
class ImageSource(TypedDict, total=False):
    """Contains the content of an image.

    Only one of `bytes` or `s3Location` should be specified.

    Attributes:
        bytes: The binary content of the image.
        location: Location of the image.
    """

    bytes: bytes
    location: SourceLocation

Location

Bases: TypedDict

A location for a document.

This type is a generic location for a document. Its usage is determined by the underlying model provider.

Source code in strands/types/media.py
18
19
20
21
22
23
24
class Location(TypedDict, total=False):
    """A location for a document.

    This type is a generic location for a document. Its usage is determined by the underlying model provider.
    """

    type: Required[str]

S3Location

Bases: Location

A storage location in an Amazon S3 bucket.

Used by Bedrock to reference media files stored in S3 instead of passing raw bytes.

  • Docs: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_S3Location.html

Attributes:

Name Type Description
type Literal['s3']

s3

uri Required[str]

An object URI starting with s3://. Required.

bucketOwner str

If the bucket belongs to another AWS account, specify that account's ID. Optional.

Source code in strands/types/media.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
class S3Location(Location, total=False):
    """A storage location in an Amazon S3 bucket.

    Used by Bedrock to reference media files stored in S3 instead of passing raw bytes.

    - Docs: https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_S3Location.html

    Attributes:
        type: s3
        uri: An object URI starting with `s3://`. Required.
        bucketOwner: If the bucket belongs to another AWS account, specify that account's ID. Optional.
    """

    # mypy doesn't like overriding this field since its a subclass, but since its just a literal string, this is fine.

    type: Literal["s3"]  # type: ignore[misc]
    uri: Required[str]
    bucketOwner: str

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
128
129
130
131
132
133
134
135
136
137
class VideoContent(TypedDict):
    """A video to include in a message.

    Attributes:
        format: The format of the video (e.g., "mp4", "avi").
        source: The source containing the video's binary content.
    """

    format: VideoFormat
    source: VideoSource

VideoSource

Bases: TypedDict

Contains the content of a video.

Only one of bytes or s3Location should be specified.

Attributes:

Name Type Description
bytes bytes

The binary content of the video.

location SourceLocation

Location of the video.

Source code in strands/types/media.py
114
115
116
117
118
119
120
121
122
123
124
125
class VideoSource(TypedDict, total=False):
    """Contains the content of a video.

    Only one of `bytes` or `s3Location` should be specified.

    Attributes:
        bytes: The binary content of the video.
        location: Location of the video.
    """

    bytes: bytes
    location: SourceLocation