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
Code Mode Compare preview

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

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 desktop

Related patterns