system
, user
)SystemMessage
represent an initial set of instructions that primes the model’s behavior. You can use a system message to set the tone, define the model’s role, and establish guidelines for responses.
HumanMessage
represents user input and interactions. They can contain text, images, audio, files, and any other amount of multimodal content.
name
field behavior varies by provider - some use it for user identification, others ignore it. To check, refer to the model provider’s reference.AIMessage
represents the output of a model invocation. They can include multimodal data, tool calls, and provider-specific metadata that you can later access.
AIMessage
objects are returned by the model when calling it, which contains all of the associated metadata in the response. However, that doesn’t mean that’s the only place they can be created/ modified from.
Providers weight/contextualize types of messages differently, which means it is sometimes helpful to create a new AIMessage
object and insert it into the message history as if it came from the model.
Attributes
AIMessageChunk
objects that can be combined:
Attributes
artifact
field stores supplementary data that won’t be sent to the model but can be accessed programmatically. This is useful for storing raw results, debugging information, or data for downstream processing without cluttering the model’s context.Example: Using artifact for raw data
content
attribute that is loosely-typed, supporting strings and lists of untyped objects (e.g., dictionaries). This allows support for provider-native structures directly in LangChain chat models, such as multimodal content and other data.
Separately, LangChain provides dedicated content types for text, reasoning, citations, multi-modal data, server-side tool calls, and other message content. See content blocks below.
LangChain chat models accept message content in the .content
attribute, and can contain:
content_blocks
when initializing a message will still populate message
content
, but provides a type-safe interface for doing so.content_blocks
property that will lazily parse the content
attribute into this standard, type-safe representation. For example, messages generated from ChatAnthropic or ChatOpenAI will include thinking
or reasoning
blocks in the format of the respective provider, but these can be lazily parsed into a consistent ReasoningContentBlock
representation:
LC_OUTPUT_VERSION
environment variable to v1
. Or,
initialize any chat model with output_version="v1"
:content_blocks
property) as a list of typed dictionaries. Each item in the list must adhere to one of the following block types:
Core
TextContentBlock
Multimodal
ImageContentBlock
"image"
AudioContentBlock
"audio"
VideoContentBlock
"video"
FileContentBlock
"file"
Tool Calling
ToolCall
ToolCallChunk
Server-Side Tool Execution
WebSearchCall
WebSearchResult
CodeInterpreterCall
Provider-Specific Blocks
NonStandardContentBlock
content
property, but rather a new property that can be used to access the content of a message in a standardized format.