Formats

Pattern
Agent Mermaid Artifact
Template-style Mermaid artifact with data-mermaidDelta streaming, diagram preview and source editor, SVG/PNG export, in-memory versions, and quick prompts — no database persistence.
IntermediateApr 2026View the full pattern on desktop


Problems solved
- Stream Mermaid diagram JSON with data-mermaidDelta UI parts
- Edit diagram source alongside a live Mermaid preview
- Export diagrams as SVG or PNG
- Keep diagram versions in memory without database persistence
Use cases
- Architecture explanation copilots
- Onboarding flow diagrams from chat
- Sequence and flowchart artifacts
- In-browser Mermaid editors for agents
AI SDK APIs
streamTextcreateUIMessageStreamgatewaytool
Tags
aimermaiddiagramarchitecturestreamingai-sdkartifacts
Requirements
- Node.js
- 24+
- Memory
- 256MB
- Other
- Vercel AI Gateway API key
Environment variables
AI_GATEWAY_API_KEYGet key
External services
openaiupstash
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View the pattern on desktop






