Docs/Foundational Primitives/Zod Tool Calling
Tool Calling & External NPM Tool Packages
AgentCore supports tool calling through custom Zod schemas as well as pre-packaged third-party tool libraries installed via NPM/PNPM.
Interactive Tool Calling Code
Select execution mode (**Gateway**, **Provider**, **Custom**) or pick models from the dropdown below:
| 1 | import { streamText, AIGateway } from '@bablusingh-dev/agentcore'; |
| 2 | import { searchTool } from 'some-tool-package'; |
| 3 | |
| 4 | const gateway = new AIGateway({ |
| 5 | defaultProvider: 'anthropic', |
| 6 | fallbackProviders: ['openai', 'anthropic', 'deepseek'], |
| 7 | }); |
| 8 | |
| 9 | const { textStream } = streamText({ |
| 10 | model: 'anthropic/claude-3-5-sonnet', |
| 11 | prompt: 'Search docs for Claude 3.5 Sonnet.', |
| 12 | tools: { |
| 13 | webSearch: searchTool, |
| 14 | }, |
| 15 | gateway, |
| 16 | }); |
| 17 | |
| 18 | for await (const textPart of textStream) { |
| 19 | console.log(textPart); |
| 20 | } |