Client-side Tools (Web SDK)
Handle tool-calls in the browser without a server URL
Overview
Use the Web SDK to handle tool-calls entirely on the client. This lets your assistant trigger UI-side effects (like showing notifications or changing state) directly in the browser.
In this guide, you’ll learn to:
- Define a client-side tool with the Web SDK
- Receive and handle
tool-callsevents on the client - Inject extra context during a call with
addMessage
Client-side tools cannot send a tool “result” back to the model. If the model must use the output of a tool to continue reasoning, implement a server-based tool instead. See: Server-based Custom Tools.
To make a tool client-side, simply do not provide a server URL. The tool specification is delivered to the browser, and the Web SDK emits tool-calls messages that your frontend can handle.
Quickstart
- Install the Web SDK:
- Start a call with your tool defined in the
model.toolsarray and subscribe toclientMessages: [‘tool-calls’]. - Listen for
message.type === ‘tool-calls’and perform the desired UI update. No response is sent back to the model. - (Optional) Inject context mid-call using
vapi.addMessage(…).
Complete example (React + Web SDK)
Inject data during the call
Use addMessage to provide extra context mid-call. This does not return results for a tool; it adds messages the model can see.
If you need the model to consume tool outputs (e.g., fetch data and continue reasoning with it), implement a server-based tool. See Custom Tools.
Key points
- Client-only execution: Omit the server URL to run tools on the client.
- One-way side effects: Client tools do not send results back to the model.
- Subscribe to events: Use
clientMessages: [‘tool-calls’]and handlemessage.type === ‘tool-calls’. - Add context: Use
vapi.addMessageto inject data mid-call.
Next steps
- Server-based tools: Learn how to return results back to the model with Custom Tools.
- API reference: See Tools API for full configuration options.