streamText( )





Pattern
Stream Text
Stream text responses from AI prompts in real-time. Includes character counting and live response rendering with useCompletion.
View the full pattern on desktop


Problems solved
- Stream text tokens to the client in real time
- Render live completions with useCompletion
- Demonstrate AI SDK streaming text over an API route
Use cases
- Streaming chat input demos
- Live writing assistants
- AI SDK streamText onboarding samples
- Character-counted prompt UIs
AI SDK APIs
streamTextuseCompletion
Tags
aiprompttext-generationstreamingai-sdkopenai
Environment variables
OPENAI_API_KEYGet key
External services
openai
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View the pattern on desktopRelated patterns


Streaming Structured Output
Stream structured output from AI prompts in real-time using streamText with Output.object(). Generate typed data with useObject and live rendering.
aiprompt+6
View pattern β


Tool Input Lifecycle Hooks
Explore tool input lifecycle hooks: onInputStart, onInputDelta, and onInputAvailable. See how to track tool input generation in real-time during streaming.
aitools+7
View pattern β



