AI SDK Agents
  • Patterns
  • Templates
streamText( )

Stream Text

Stream text responses from AI prompts in real-time. Includes character counting and live response rendering with useCompletion.

View Full PatternView Full Pattern on Desktop
Stream Text previewStream Text preview

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 PatternView Pattern on Desktop

Related Patterns

Streaming Structured Output previewStreaming Structured Output preview

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.

Tool Input Lifecycle Hooks previewTool Input Lifecycle Hooks preview

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.

Preliminary Tool Results previewPreliminary Tool Results preview

Preliminary Tool Results

Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.

Generate Text previewGenerate Text preview

Generate Text

Generate text from prompts using AI. Simple interface with character counting and response rendering.

End of Pattern