Primary parts of the message (e.g., text, image, value, or function).
OptionalidOptional stable identifier for deduplication or threading.
Author of the message.
OptionalsignatureOptional signature for the thinking field.
This is only applicable to certain LLM APIs that require a signature as part of the thinking payload.
OptionalthinkingInternal “thinking” text used by some models before producing final output.
Optionaltool_Tool-call parts emitted alongside the main contents.
A chat message generated by a user, model, or tool.
Messageis the concrete, non-streaming container used by the application to store, transmit, or feed structured content into models or tools. It can represent various kinds of messages, including user input, assistant responses, tool-call outputs, or signed thinking metadata.Note that many different kinds of messages can be produced. For example, a language model may internally generate a
thinkingtrace before emitting its final output, in order to improve reasoning accuracy. In other cases, a model may produce function calls — structured outputs that instruct external tools to perform specific actions.This struct is designed to handle all of these situations in a unified way.
Example
Rust