- Role - Identifies the message type (e.g.
system,user) - Content - Represents the actual content of the message (like text, images, audio, documents, etc.)
- Metadata - Optional fields such as response information, message IDs, and token usage
Basic usage
The simplest way to use messages is to create message objects and pass them to a model when invoking.Text prompts
Text prompts are strings - ideal for straightforward generation tasks where you don’t need to retain conversation history.- You have a single, standalone request
- You don’t need conversation history
- You want minimal code complexity
Message prompts
Alternatively, you can pass in a list of messages to the model by providing a list of message objects.- Managing multi-turn conversations
- Working with multimodal content (images, audio, files)
- Including system instructions
Dictionary format
You can also specify messages directly in OpenAI chat completions format.Message types
- System message - Tells the model how to behave and provide context for interactions
- Human message - Represents user input and interactions with the model
- AI message - Responses generated by the model, including text content, tool calls, and metadata
- Tool message - Represents the outputs of tool calls
System message
ASystemMessage 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.
Basic instructions
Detailed persona
Human message
AHumanMessage represents user input and interactions. They can contain text, images, audio, files, and any other amount of multimodal content.
Text content
Message metadata
Add metadata
The
name field behavior varies by provider—some use it for user identification, others ignore it. To check, refer to the model provider’s reference.Notifications
An agent harness sometimes adds a human message that the user did not type, such as a background task update or a conversation summary. Notification metadata marks these messages so that your frontend can show them differently from user input.Notification metadata requires
langchain-core>=1.7.2.add_notification_metadata returns a copy of a HumanMessage with a source that names the feature that added it, and optional data with that feature’s fields:
get_notification_metadata returns the source and data of a notification, or None for any other message:
AI message
AnAIMessage 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.
Providers weigh/contextualize types of messages differently, which means it is sometimes helpful to manually create a new AIMessage object and insert it into the message history as if it came from the model.
Attributes
Attributes
The standardized content blocks of the message.
A unique identifier for the message (either automatically generated by LangChain or returned in the provider response)
Tool calls
When models make tool calls, they’re included in theAIMessage:
Token usage
AnAIMessage can hold token counts and other usage metadata in its usage_metadata field:
UsageMetadata for details.
Streaming and chunks
During streaming, you’ll receiveAIMessageChunk objects that can be combined into a full message object:
Tool message
For models that support tool calling, AI messages can contain tool calls. Tool messages are used to pass the results of a single tool execution back to the model. Tools can generateToolMessage objects directly. Below, we show a simple example. Read more in the tools guide.
Attributes
Attributes
The ID of the tool call that this message is responding to. Must match the ID of the tool call in the
AIMessage.The
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 retrieval metadata
Example: Using artifact for retrieval metadata
For example, a retrieval tool could retrieve a passage from a document for reference by a model. Where message See the RAG tutorial for an end-to-end example of building retrieval agents with LangChain.
content contains text that the model will reference, an artifact can contain document identifiers or other metadata that an application can use (e.g., to render a page). See example below:Message content
You can think of a message’s content as the payload of data that gets sent to the model. Messages have acontent 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.
This may contain either:
- A string
- A list of content blocks in a provider-native format
- A list of LangChain’s standard content blocks
Standard content blocks
LangChain provides a standard representation for message content that works across providers. Message objects implement acontent_blocks property that will lazily parse the content attribute into a 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 can be lazily parsed into a consistent ReasoningContentBlock representation:
- Anthropic
- OpenAI
Serializing standard contentIf an application outside of LangChain needs access to the standard content block
representation, you can opt-in to storing content blocks in message content.To do this, you can set the
LC_OUTPUT_VERSION environment variable to v1. Or,
initialize any chat model with output_version="v1":Multimodal
Multimodality refers to the ability to work with data that comes in different forms, such as text, audio, images, and video. LangChain includes standard types for these data that can be used across providers. Chat models can accept multimodal data as input and generate it as output. Below we show short examples of input messages featuring multimodal data.Extra keys can be included top-level in the content block or nested in
"extras": {"key": value}.OpenAI,
for example, requires a filename for PDFs. See the provider page
for your chosen model for specifics.Content block reference
Content blocks are represented (either when creating a message or accessing thecontent_blocks property) as a list of typed dictionaries. Each item in the list must adhere to one of the following block types:
Core
Core
TextContentBlock
TextContentBlock
ReasoningContentBlock
ReasoningContentBlock
RefusalContentBlock
RefusalContentBlock
Purpose: An explicit refusal that the model provider reports, such as an OpenAI Example:
refusal content part, an Anthropic stop_reason="refusal", or a Gemini safety block. LangChain does not detect refusals that the model writes as ordinary text. Requires langchain-core>=1.7.5.Additional provider-specific data, such as Anthropic’s refusal
category or Gemini’s finish_reason or block_reasonMultimodal
Multimodal
ImageContentBlock
ImageContentBlock
Purpose: Image data
Image MIME type (e.g.,
image/jpeg, image/png). Required for base64 data.AudioContentBlock
AudioContentBlock
Purpose: Audio data
Audio MIME type (e.g.,
audio/mpeg, audio/wav). Required for base64 data.VideoContentBlock
VideoContentBlock
Purpose: Video data
Video MIME type (e.g.,
video/mp4, video/webm). Required for base64 data.FileContentBlock
FileContentBlock
Purpose: Generic files (PDF, etc)
File MIME type (e.g.,
application/pdf). Required for base64 data.PlainTextContentBlock
PlainTextContentBlock
Purpose: Document text (
.txt, .md)MIME type of the text (e.g.,
text/plain, text/markdown)Tool Calling
Tool Calling
ToolCall
ToolCall
ToolCallChunk
ToolCallChunk
Server-Side Tool Execution
Server-Side Tool Execution
ServerToolCall
ServerToolCall
ServerToolCallChunk
ServerToolCallChunk
ServerToolResult
ServerToolResult
Provider-Specific Blocks
Provider-Specific Blocks
NonStandardContentBlock
NonStandardContentBlock
Purpose: Provider-specific escape hatchUsage: For experimental or provider-unique featuresWhen
langchain-core adds a standard block type, payloads that match it move out of non_standard and into the new type. Branch on type instead of relying on a payload staying non_standard, and upgrade provider packages together with langchain-core.Content blocks were introduced as a new property on messages in LangChain v1 to standardize content formats across providers while maintaining backward compatibility with existing code.Content blocks are not a replacement for the
content property, but rather a new property that can be used to access the content of a message in a standardized format.Serialization
You can serialize messages to plain objects for storage and deserialize back to message instances. This is useful for persisting conversation history and resuming sessions.Use with chat models
Chat models accept a sequence of message objects as input and return anAIMessage as output. Interactions are often stateless, so that a simple conversational loop involves invoking a model with a growing list of messages.
Refer to the below guides to learn more:
- Built-in features for persisting and managing conversation histories
- Strategies for managing context windows, including trimming and summarizing messages
Connect these docs to your agent of choice via MCP for real-time answers.

