LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    ⌘I

    LangChain Assistant

    Ask a question to get started

    Enter to send•Shift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coremessagescontentFileContentBlock
    Class●Since v1.0

    FileContentBlock

    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).

    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
    Copy
    FileContentBlock()

    Bases

    TypedDict

    Constructors

    constructor
    __init__
    NameType
    typeLiteral['file']
    idNotRequired[str]
    file_idNotRequired[str]
    mime_typeNotRequired[str]
    indexNotRequired[int | str]
    urlNotRequired[str]
    base64NotRequired[str]
    extrasNotRequired[dict[str, Any]]

    Attributes

    attribute
    type: Literal['file']

    Type of the content block. Used for discrimination.

    attribute
    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_'))
    attribute
    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.

    attribute
    mime_type: NotRequired[str]

    MIME type of the file.

    Required for base64 data.

    Examples from IANA

    attribute
    index: NotRequired[int | str]

    Index of block in aggregate response. Used during streaming.

    attribute
    url: NotRequired[str]

    URL of the file.

    attribute
    base64: NotRequired[str]

    Data as a base64 string.

    attribute
    extras: NotRequired[dict[str, Any]]

    Provider-specific metadata. This shouldn't be used for the file data itself.

    View source on GitHub