INT
Nov 25

Dynamic Tool

Create dynamic tools with runtime-generated schemas using dynamicTool. Demonstrates unit conversion tools where schema adapts based on conversion type (temperature, length, weight, currency) and supports dynamic model selection.

View Full Pattern on Desktop
Dynamic Tool preview

Problems Solved

  • Create tools with runtime-generated schemas
  • Adapt tool schemas based on user selection
  • Support dynamic model selection
  • Demonstrate dynamic tool creation patterns
  • Handle tools with unknown schemas at compile time

Use Cases

  • Unit conversion tools with dynamic schemas
  • MCP (Model Context Protocol) tools
  • User-defined functions at runtime
  • Tools loaded from external sources
  • Dynamic tool configuration based on user input

AI SDK APIs

streamTextconvertToModelMessagesdynamicTooluseChatprepareSendMessagesRequest

Tags

aitoolsdynamic-toolruntime-toolsunit-converterschema-generationdynamic-schemaai-sdktool-apimodel-selection

Requirements

Node.js
18+
Memory
512MB
Other
  • AI API key (OpenAI, Anthropic, or Google)

Environment Variables

External Services

openaianthropicgoogle

Ready to use?

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

View Pattern on Desktop
End of Pattern