streamText( )

Stream Text

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

Open Live PreviewView 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.

Open Live PreviewView 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
ai sdk agents

Docs

  • Get Started
  • About
  • Theming
  • Changelog
  • AI SDK Blocks
  • AI Elements
  • Agent Patterns
  • Building Agents
  • Router Agents
  • Context Engineering
  • Few-shot Prompting
  • Button Group & Input Group

Blocks

  • Chat Gpt
  • Chat Claude
  • Chat Grok
  • Generate Speech (OpenAI)
  • Transcribe Audio (OpenAI)
  • Generate Text
  • Stream Text
  • Streaming Structured Output
  • OpenAI Structured Output
  • Claude Structured Output
  • Gemini Structured Output
  • Generate Image (OpenAI)
  • Generate Image (Fal.ai)
  • Generate Image (Google Gemini)
  • Generate Speech (ElevenLabs)
  • Transcribe Audio (ElevenLabs)
  • Search - Exa AI (robust)
  • Search - Firecrawl (robust)
  • Scrape - Cheerio (lightweight)
  • Scrape - Jina AI (advanced)
  • Scrape - Markdown.new (free)
  • Agent Routing Pattern
  • JSON Render Email
  • HIL Tool Approval Basic
  • Basic Chat Interface
  • Plan
  • Tool Approval
  • Sources & Citations
  • Task Management Demo
  • Queue
  • Parallel Processing Pattern
  • CSV Editor Artifact
  • HIL Agentic Context Builder
  • Chart Generation Artifact
  • Tool Execution
  • Reasoning
  • AI SDK Prompt Few-Shot Editor
  • AI Profile Enrichment Form
  • Cheerio Web Scraper
  • Jina AI Web Scraper
  • Cloudflare Markdown.new Web Scraper
  • Web Search Tool
  • PDF Analysis Tool
  • Image Generation Demo
  • Inline Citations Demo
  • AI SDK Gemini Flash Text
  • AI SDK Nano Banana Image
  • AI SDK Nano Banana Image Edit
  • AI SDK Nano Banana Image Merge
  • Multi-Step Tool Pattern
  • Orchestrator-Worker Pattern
  • Evaluator-Optimizer Pattern
  • Claude Web Search Tool
  • Exa Web Search Tool
  • @exalabs webSearch Tool
  • Firecrawl Scrape Tool Chat
  • Workflow - URL Analysis
  • HIL Needs Approval
  • HIL Inquire Multiple Choice
  • HIL Inquire Text Input
  • Tool Input Lifecycle Hooks
  • Preliminary Tool Results
  • Tool API Context
  • Tool Call Repair
  • Dynamic Tool
  • Structured Agent Output: Output.choice
  • Structured Agent Output: Output.array
  • Chat-Base Clone
  • AI Form Generator
  • Sub-Agent Orchestrator
  • Research Agent Chain
  • Human in the Loop Plan Builder Agent
  • Marketing Plan & Implement Agent
  • Branding Agent
  • Brand Product Placement Generator (Nano Banana)
  • Competitor Research Agent
  • Data Analysis Agent
  • Accessibility Audit Agent
  • SEO Audit
  • Reddit Product Validation Agent
  • AI Wizard Brand Strategy
  • Levee User Research
  • JSON Render Shadcn
  • JSON Render Three.js
  • JSON Render React
  • JSON Render PDF
  • JSON Render Image
  • Firecrawl Brand PDF
  • Firecrawl Landing Page Teardown PDF
  • JSON Render Remotion
  • Code Block 1
  • Code Block 2
  • Code Block 3
  • Feature Grid 1
  • Bento Layout 1
  • Model Comparison
  • Model Comparison Compact
  • Model Comparison Hover
  • Comparison Table 1
  • Integration Showcase 1
  • AI Integrations Circle
  • Agent ROI Calculator
  • Changelog 1
  • Evaluator Workflow Pattern
  • Orchestrator-Worker Workflow Pattern
  • Parallel Review Workflow Pattern
  • Routing Workflow Pattern
  • Sequential Workflow Pattern

Categories

  • Agents
  • Chat
  • Generation
  • Analysis
  • Tools
  • Artifacts
  • Data
  • Marketing
  • Model Comparison
  • Demos
  • Examples
  • Pricing
  • Integrations
  • Use Cases
  • Free

Explore

  • AI Agent Builder
  • AI Agent Frameworks
  • AI Agent Development
  • AI Agent Skills
  • AI Agent Orchestration
  • AI Agent Platform
  • AI Agent GitHub
  • AI SDK Vercel
  • AI SDK v6
  • AI SDK UI
  • AI SDK Google
  • AI SDK MCP
  • AI SDK Examples

Quick Links

  • Patterns
  • Directory
  • Pricing
  • Login
  • Signup