Docs
CodeRabbit
Cloudflare
Railway
OpenRouter
Netlify
Clerk
WorkOS
AG Grid
SerpAPI
Unkey
Prisma
Electric
Sentry
CodeRabbit
Cloudflare
Railway
OpenRouter
Netlify
Clerk
WorkOS
AG Grid
SerpAPI
Unkey
Prisma
Electric
Sentry
Class References
Function References
Interface References
Type Alias References
Variable References
Function References

normalizeToUIMessage

Function: normalizeToUIMessage()

ts
function normalizeToUIMessage(message, generateId): UIMessage;
function normalizeToUIMessage(message, generateId): UIMessage;

Defined in: packages/ai/src/activities/chat/messages.ts:527

Normalize a message (UIMessage or ModelMessage) to a UIMessage Ensures the message has an ID and createdAt timestamp

Parameters

message

Either a UIMessage or ModelMessage

ModelMessage< | string | ContentPart<unknown, unknown, unknown, unknown, unknown>[] | null> | UIMessage<unknown>

generateId

() => string

Function to generate a message ID if needed

Returns

UIMessage

A UIMessage with guaranteed id and createdAt