Call Tool Multiple Steps
Tools Multi-step Chaining
Chain multiple tool calls where the output of one becomes the input of another. The AI autonomously decides the execution order to fulfill the user's request.
The Chain in Action
When you ask "What's the weather where I am?", the AI first calls getLocation to find your city, then uses that
result to call getWeather. All automatic—no manual
orchestration needed.
Demo
Watch the AI chain location → weather calls!
Execution Flow
flow.ts
Copy
Define Multiple Tools
tools.ts
Copy
Server Endpoint
Simply pass all tools to streamText. The AI handles
the orchestration.
+server.ts
Copy
Client Component
The client uses the Chat class to send messages and
render tool call results as they stream in.
+page.svelte
Copy