?
Message
TypeRepresents one turn in a thread's history, from the user or the assistant, including any tool calls.
One entry in a thread's messages. A user or assistant message carries its text in content; an assistant turn may include the toolCalls it requested (each a small object with an id, a method name, and input), and a tool result carries the toolCallId it answers and the stringified output. User messages may also carry attachments as CDN URLs.
Message.ts
interface Message { role: 'user' | 'assistant' content: string attachments?: string[] toolCalls?: ToolCall[] toolCallId?: string isToolError?: boolean }
Fields
role
'user' | 'assistant'
Who authored the message.
content
string
The message text. For a tool result, the JSON-stringified output.
attachments?
string[]
CDN URLs attached to the message (user messages only).
toolCalls?
ToolCall[]
Tool calls the assistant requested; each ToolCall carries an id, a method name, and the input arguments (assistant messages only).
toolCallId?
string
The id of the tool call this message is a result for.
isToolError?
boolean
True when a tool result represents an error.
Render by role
thread.messages.forEach((m: Message) => {
if (m.role === 'user') renderUser(m.content, m.attachments);
else renderAssistant(m.content, m.toolCalls);
});