Message Components

Pattern

Tool Execution

Connect AI agents with external APIs and services. Demonstrates tool calling with weather data, error handling, and visual feedback.

IntermediateOct 2025View the full pattern on desktop
Tool Execution preview

Problems solved

  • Render AI SDK tool invocations with dedicated tool UI parts
  • Show tool input, output, and status during streaming
  • Demonstrate tool calling inside an AI Elements chat shell

Use cases

  • Tool-calling chat demos
  • Debugging UIs for tool arguments and results
  • Product tours of AI Elements Tool
  • Assistants that surface tool activity inline

AI SDK APIs

streamTexttools:convertToModelMessages

Tags

aitoolsai-sdktool-executiondemoweather-api

Requirements

Node.js
24+
Memory
512MB
Other
  • OpenAI API key

Environment variables

External services

openai

Ready to use?

View the full interactive pattern with live preview and copy the source code.

View the pattern on desktop

Related patterns