Message Components

Pattern
Basic Chat Interface
Chat interface with streaming responses and message history. Includes typing indicators and message status tracking.
BeginnerOct 2025View the full pattern on desktop


Problems solved
- Stream chat responses with message history in the UI
- Switch between a user-selected model and Perplexity Sonar for web search
- Enable source and reasoning parts in the UI message stream
Use cases
- Basic AI chat products
- Model-picker chat experiences
- Search-backed assistant demos
- AI Elements conversation shells
AI SDK APIs
streamTextconvertToModelMessagescreateUIMessageStreamResponseuseChat
Tags
aichatai-sdkopenai
Requirements
- Node.js
- 24+
- Memory
- 512MB
- Other
- OpenAI API key
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 desktop






