This page contains reference documentation for Messages. See the docs for conceptual guides, tutorials, and examples on using Messages.
Message from an AI.
An AIMessage is returned from a chat model as a response to a prompt.
This message represents the output of the model and consists of both the raw output as returned by the mod
Message chunk from an AI (yielded when streaming).
Message from the user.
A HumanMessage is a message that is passed in from a user to the model.
Message for priming AI behavior.
The system message is usually passed in as the first of a sequence of input messages.
Message for passing the result of executing a tool back to a model.
ToolMessage objects contain the result of a tool invocation. Typically, the result
is encoded inside the content field.
`tool_
Represents an AI's request to call a tool.
Allowance for errors made by LLM.
Here we add an error key to surface errors made during generation
(e.g., invalid JSON arguments.)
A chunk of a tool call (yielded when streaming).
When merging ToolCallChunks (e.g., via AIMessageChunk.__add__),
all string attributes are concatenated. Chunks are only merged if their
values of
Tool call that is executed server-side.
For example: code execution, web search, etc.
A chunk of a server-side tool call (yielded when streaming).
Result of a server-side tool call.
Text output from a LLM.
This typically represents the main text content of a message, such as the response from a language model or the text of a user message.
`crea
Annotation for citing data from a document.
start/end indices refer to the response text,
not the source text. This means that the indices are relative to the model's
re
Provider-specific annotation format.
Reasoning output from a LLM.
create_reasoning_block may also be used as a factory to create a
ReasoningContentBlock. Benefits include:
Image data.
create_image_block may also be used as a factory to create an
ImageContentBlock. Benefits include:
Video data.
create_video_block may also be used as a factory to create a
VideoContentBlock. Benefits include:
Audio data.
create_audio_block may also be used as a factory to create an
AudioContentBlock. Benefits include:
Plaintext data (e.g., from a .txt or .md document).
A PlainTextContentBlock existed in langchain-core<1.0.0. Although the
name has carried over, the structure has changed si
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
Provider-specific content data.
This block contains data for which there is not yet a standard type.
The purpose of this block should be to simply hold a provider-specific payload. If a provider's n
Usage metadata for a message, such as token counts.
This is a standard representation of token usage that is consistent across models.
Breakdown of input token counts.
Does not need to sum to full input token count. Does not need to have all keys.
Breakdown of output token counts.
Does not need to sum to full output token count. Does not need to have all keys.