FileContentBlock Class — langchain Architecture
Architecture documentation for the FileContentBlock class in content.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD bda018ff_3f9e_0f08_c457_9d780bcd49a5["FileContentBlock"] c7f11daf_e104_efbe_7225_f1d6da8e8630["content.py"] bda018ff_3f9e_0f08_c457_9d780bcd49a5 -->|defined in| c7f11daf_e104_efbe_7225_f1d6da8e8630
Relationship Graph
Source Code
libs/core/langchain_core/messages/content.py lines 721–782
class FileContentBlock(TypedDict):
"""File data that doesn't fit into other multimodal block types.
This block is intended for files that are not images, audio, or plaintext. For
example, it can be used for PDFs, Word documents, etc.
If the file is an image, audio, or plaintext, you should use the corresponding
content block type (e.g., `ImageContentBlock`, `AudioContentBlock`,
`PlainTextContentBlock`).
!!! note "Factory function"
`create_file_block` may also be used as a factory to create a
`FileContentBlock`. Benefits include:
* Automatic ID generation (when not provided)
* Required arguments strictly validated at creation time
"""
type: Literal["file"]
"""Type of the content block. Used for discrimination."""
id: NotRequired[str]
"""Unique identifier for this content block.
Used for tracking and referencing specific blocks (e.g., during streaming).
Not to be confused with `file_id`, which references an external file in a
storage system.
Either:
- Generated by the provider
- Generated by LangChain upon creation (`UUID4` prefixed with `'lc_'`))
"""
file_id: NotRequired[str]
"""Reference to the file in an external file storage system.
For example, a file ID from OpenAI's Files API or another cloud storage provider.
This is distinct from `id`, which identifies the content block itself.
"""
mime_type: NotRequired[str]
"""MIME type of the file.
Required for base64 data.
[Examples from IANA](https://www.iana.org/assignments/media-types/media-types.xhtml)
"""
index: NotRequired[int | str]
"""Index of block in aggregate response. Used during streaming."""
url: NotRequired[str]
"""URL of the file."""
base64: NotRequired[str]
"""Data as a base64 string."""
extras: NotRequired[dict[str, Any]]
"""Provider-specific metadata. This shouldn't be used for the file data itself."""
Defined In
Source
Frequently Asked Questions
What is the FileContentBlock class?
FileContentBlock is a class in the langchain codebase, defined in libs/core/langchain_core/messages/content.py.
Where is FileContentBlock defined?
FileContentBlock is defined in libs/core/langchain_core/messages/content.py at line 721.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free