Skip to Content
SdkVercelInternalFunctionsmapMessagesToCompletionPayload

mapMessagesToCompletionPayload

mapMessagesToCompletionPayload(messages: UIMessage<unknown, UIDataTypes, UITools>[]): LlmapiMessage[]

Defined in: src/vercel/messages.ts:15 

Converts an array of Vercel AI UIMessage objects into the LlmapiMessage format that the Portal API expects.

  • Non text-only parts and unsupported roles are ignored.
  • Text parts are merged with double newlines, matching the structure that postApiV1ChatCompletions accepts.

Parameters

ParameterTypeDescription

messages

UIMessage<unknown, UIDataTypes, UITools>[]

The UI layer conversation history received from createUIMessageStreamResponse.

Returns

LlmapiMessage[]

A clean array of Portal-ready messages, filtered to user, assistant, and system roles.

Last updated on