toUIMessageChunk
A function in the AI SDK that converts a model output stream into UI message chunks; its output determines which content front-end components can render.
Core Facts
Timeline (last 90 days)
toUIMessageChunk is the adapter function that converts model-layer streaming chunks into UI message chunks consumable by the frontend, and is the protocol boundary between the server and frontend hooks such as useChat.
The two interfaces toUIMessageChunk and createModelCallToUIChunkTransform now both accept and forward the four parameters sendReasoning, sendSources, onError, and redactToolErrors
@ai-sdk/workflow 2.0.123 changes toUIMessageChunk's separate switch branches to directly delegate to the same-named implementation in AI SDK Core
Both transformation functions of @ai-sdk/workflow, toUIMessageChunk and createModelCallToUIChunkTransform, now accept and forward the sendReasoning, sendSources, onError, and redactToolErrors parameters.
In @ai-sdk/workflow version 2.0.123, toUIMessageChunk no longer maintains its own switch statement, but instead delegates standard stream chunks to the core implementation in the ai package.
`@ai-sdk/workflow`'s `toUIMessageChunk` now delegates to AI SDK Core, thereby preserving the provider's `custom` parts, tool result and error metadata, `reasoning-file`, `tool-approval-response`, and citation information.
Both functions of `@ai-sdk/workflow` now accept and forward the `sendReasoning`, `sendSources`, `onError`, and `redactToolErrors` parameters, and the default value of `sendSources` is `false`.
All Facts (7)
In @ai-sdk/workflow version 2.0.123, toUIMessageChunk no longer maintains its own switch statement, but instead delegates standard stream chunks to the core implementation in the ai package.
75%UnverifiedBoth functions of `@ai-sdk/workflow` now accept and forward the `sendReasoning`, `sendSources`, `onError`, and `redactToolErrors` parameters, and the default value of `sendSources` is `false`.
70%UnverifiedtoUIMessageChunk is the adapter function that converts model-layer streaming chunks into UI message chunks consumable by the frontend, and is the protocol boundary between the server and frontend hooks such as useChat.
50%Unverified@ai-sdk/workflow 2.0.123 changes toUIMessageChunk's separate switch branches to directly delegate to the same-named implementation in AI SDK Core
50%UnverifiedThe two interfaces toUIMessageChunk and createModelCallToUIChunkTransform now both accept and forward the four parameters sendReasoning, sendSources, onError, and redactToolErrors
50%Unverified`@ai-sdk/workflow`'s `toUIMessageChunk` now delegates to AI SDK Core, thereby preserving the provider's `custom` parts, tool result and error metadata, `reasoning-file`, `tool-approval-response`, and citation information.
50%UnverifiedBoth transformation functions of @ai-sdk/workflow, toUIMessageChunk and createModelCallToUIChunkTransform, now accept and forward the sendReasoning, sendSources, onError, and redactToolErrors parameters.
50%