Vercel
class Vercel
Methods
Convert messages or conversation message models into UI message arrays for hydrating useChat.
Settle a hydrated tool part with its result, wherever the call was rendered.
Settle a hydrated tool part with its failure text.
Get a message's attachments as file instances.
Get a message's tool calls as their array representations.
Create messages from a list of Vercel AI SDK UI messages (a useChat request body).
Create a message from a single Vercel AI SDK UI message (parts-based) array.
Create tool results from a UI message's settled tool parts.
Get the tool approval responses awaiting execution on a UI message, keyed by tool call id.
Filter the given parts down to the tool parts.
Get the tool name encoded in a UI tool part's type.
Create a file instance from a Vercel AI SDK UI message file part.
Create a base64 file instance from a data URL.
Details
at line 37
static Chat
chat(Request|iterable $input)
Create a chat instance from a useChat request or its UI message list.
at line 50
static array
toUiMessages(iterable $messages)
Convert messages or conversation message models into UI message arrays for hydrating useChat.
at line 108
static protected array
uiPartsFrom(Message|ConversationMessage $message)
Create the UI message parts for a single message.
at line 161
static protected void
applyUiToolOutput(array $result, array $partRefs, string $id, mixed $output, bool $denied)
Settle a hydrated tool part with its result, wherever the call was rendered.
at line 186
static protected void
applyUiToolError(array $result, array $partRefs, string $id, mixed $error)
Settle a hydrated tool part with its failure text.
at line 204
static protected Collection
attachmentsFrom(Message|ConversationMessage $message)
Get a message's attachments as file instances.
at line 221
static protected iterable
toolCallArraysFrom(Message|ConversationMessage $message)
Get a message's tool calls as their array representations.
at line 235
static protected array|null
uiFilePartFrom(File $file)
Create a UI message file part from a file instance.
at line 266
static array
fromUiMessages(iterable $messages)
Create messages from a list of Vercel AI SDK UI messages (a useChat request body).
at line 292
static Message
fromUiMessage(array $message)
Create a message from a single Vercel AI SDK UI message (parts-based) array.
at line 321
static protected Collection
toolResultsFrom(array $message)
Create tool results from a UI message's settled tool parts.
at line 342
static array
approvalResponsesFrom(array $message)
Get the tool approval responses awaiting execution on a UI message, keyed by tool call id.
at line 358
static protected Collection
toolParts(iterable $parts)
Filter the given parts down to the tool parts.
at line 371
static protected string
toolName(array $part)
Get the tool name encoded in a UI tool part's type.
at line 381
static protected File|null
fileFrom(array $part)
Create a file instance from a Vercel AI SDK UI message file part.
at line 410
static protected File|null
fileFromDataUrl(string $url, string $mime)
Create a base64 file instance from a data URL.