tool( )





Pattern
Code Mode Compare
See if stock covers an open order. The model writes one program that calls both lookups and subtracts.
BeginnerSep 2026View the full pattern on desktop


Problems solved
- Call independent tools from one program
- Hide host tools from direct model tool calls
- Return one comparison instead of two tool rounds
Use cases
- Side-by-side inventory and demand checks
- Teaching experimental_toolCallers
- One-step comparisons across two stub tools
AI SDK APIs
generateTextexperimental_codeModeToolexperimental_toolCallers
Tags
code-modetoolsexperimentaltool-callersai-sdk
Requirements
- Node.js
- 22+
- Memory
- 256MB
- Other
- Vercel AI Gateway API key
- Node.js 22 or newer. Code mode is not available on the edge.
Environment variables
AI_GATEWAY_API_KEYGet key
External services
vercel-ai-gatewayupstash
Ready to use?
View the full interactive pattern with live preview and copy the source code.
View the pattern on desktopRelated patterns


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.
aitools+7
View pattern →


Preliminary Tool Results
Return preliminary tool results using async iterables. Stream status updates during tool execution before the final result is available.
aitools+6
View pattern →



