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-coremessagescontentPlainTextContentBlock
    Class●Since v1.0

    PlainTextContentBlock

    Copy
    PlainTextContentBlock()

    Bases

    TypedDict

    Constructors

    Attributes

    View source on GitHub
    constructor
    __init__
    NameType
    typeLiteral['text-plain']
    idNotRequired[str]
    file_idNotRequired[str]
    mime_typeLiteral['text/plain']
    indexNotRequired[int | str]
    urlNotRequired[str]
    base64NotRequired[str]
    textNotRequired[str]
    titleNotRequired[str]
    contextNotRequired[str]
    extrasNotRequired[dict[str, Any]]
    attribute
    type: Literal['text-plain']

    Type of the content block. Used for discrimination.

    attribute
    id: NotRequired[str]

    Unique identifier for this content block.

    Either:

    • Generated by the provider
    • Generated by LangChain upon creation (UUID4 prefixed with 'lc_'))
    attribute
    file_id: NotRequired[str]

    Reference to the plaintext file in an external file storage system.

    For example, OpenAI or Anthropic's Files API.

    attribute
    mime_type: Literal['text/plain']

    MIME type of the file.

    Required for base64 data.

    attribute
    index: NotRequired[int | str]

    Index of block in aggregate response. Used during streaming.

    attribute
    url: NotRequired[str]

    URL of the plaintext.

    attribute
    base64: NotRequired[str]

    Data as a base64 string.

    attribute
    text: NotRequired[str]

    Plaintext content. This is optional if the data is provided as base64.

    attribute
    title: NotRequired[str]

    Title of the text data, e.g., the title of a document.

    attribute
    context: NotRequired[str]

    Context for the text, e.g., a description or summary of the text's content.

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

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

    Plaintext data (e.g., from a .txt or .md document).

    Note

    A PlainTextContentBlock existed in langchain-core<1.0.0. Although the name has carried over, the structure has changed significantly. The only shared keys between the old and new versions are type and text, though the type value has changed from 'text' to 'text-plain'.

    Note

    Title and context are optional fields that may be passed to the model. See Anthropic example.

    Factory function

    create_plaintext_block may also be used as a factory to create a PlainTextContentBlock. Benefits include:

    • Automatic ID generation (when not provided)
    • Required arguments strictly validated at creation time