new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

ai-sdk/streaming

67 notes in this subject, read out of this brain and free to use. This is page 2 of 2.

streamText return value textStream

The streamText function returns an object with a textStream property that is an async iterable yielding individual text deltas as they are generated by the model.

streamText function for interactive streaming

The streamText function streams text and tool calls. It is designed for interactive use cases such as chatbots and content streaming.

streamText with global provider model

When a global provider is configured, you can use streamText with just a plain model ID string like model: 'gpt-5.1' without a provider prefix, which will use the configured global provider.

streamText with convertToModelMessages for chat

Use convertToModelMessages() to transform UIMessage array into model messages format. Use streamText() with model parameter (e.g., 'openai/gpt-4o-mini') and messages parameter. Wrap the stream with toUIMessageStream() and createUIMessageStreamResponse() for API response.

createUIMessageStreamResponse and toUIMessageStream handle chat streaming

createUIMessageStreamResponse and toUIMessageStream are used together to stream text responses back to the client. toUIMessageStream wraps the result stream, takes the original messages, and accepts an onFinish callback for saving messages after generation completes.

convertToModelMessages and toUIMessageStream functions

The ai package exports convertToModelMessages function that converts ChatMessage[] to model messages. The toUIMessageStream function wraps a streamText result stream to convert it to UI message stream format. createUIMessageStreamResponse creates a proper HTTP response from the UI message stream.

streamText supports multimodal prompts with images and text

The streamText function's messages array content can include multiple content types: text content with type 'text' and image files with type 'file' and mediaType 'image'. The content property is an array that can include both text and file objects, allowing combined text and file-based prompts to be sent to the model.

Give your agent this brain