ChatMessage
type ChatMessage = | { content: string; role: "system";} | { content: string | ContentPart[]; role: "user";} | { content: string; reasoning?: string; reasoningDetails?: unknown[]; reasoningItems?: ReasoningItems; role: "assistant"; toolCalls?: ToolCall[];} | { content: string; images?: ImagePart[]; name: string; role: "tool"; toolCallId: string;};Defined in: core/src/types.ts:87
Union Members
Section titled “Union Members”Type Literal
Section titled “Type Literal”{ content: string; role: "system";}Type Literal
Section titled “Type Literal”{ content: string | ContentPart[]; role: "user";}Type Literal
Section titled “Type Literal”{ content: string; reasoning?: string; reasoningDetails?: unknown[]; reasoningItems?: ReasoningItems; role: "assistant"; toolCalls?: ToolCall[];}content
Section titled “content”content: string;reasoning?
Section titled “reasoning?”optional reasoning?: string;The model’s chain-of-thought. Thinking-mode providers require it
replayed on a turn that made a tool call (DeepSeek 400s without it).
OpenAI-shape serializes it as reasoning_content; Anthropic-shape
drops it, since its thinking blocks carry signatures we never capture.
A turn that disables thinking must not carry it. Mixing the two is
unsupported. stripReasoning below is that rule, once.
reasoningDetails?
Section titled “reasoningDetails?”optional reasoningDetails?: unknown[];OpenRouter’s normalized reasoning payload, arriving on the stream and riding back UNMODIFIED on the next turn’s assistant message.
Opaque on purpose, with the same contract as Gemini’s thoughtSignature,
and for the same reason: it is the provider’s own record of how it got
here, and reading, reshaping or dropping it costs the model its
continuity across a tool round. Absent on every other dialect.
reasoningItems?
Section titled “reasoningItems?”optional reasoningItems?: ReasoningItems;The ChatGPT backend’s own reasoning items, encrypted, riding back
UNMODIFIED on the next turn so the model keeps its chain of thought.
Tagged with the provider that made them: only that provider replays
them, because another vendor (after a fallback) would reject them.
Opaque, like reasoningDetails.
role: "assistant";toolCalls?
Section titled “toolCalls?”optional toolCalls?: ToolCall[];Type Literal
Section titled “Type Literal”{ content: string; images?: ImagePart[]; name: string; role: "tool"; toolCallId: string;}content
Section titled “content”content: string;images?
Section titled “images?”optional images?: ImagePart[];Images a tool hands back (a screenshot, a rendered chart).
name: string;role: "tool";toolCallId
Section titled “toolCallId”toolCallId: string;