Tool calling
Tool calling lets models invoke functions you define. Gateway passes your tool definitions to the model, the model suggests which tool to call with what arguments, and your application executes it and sends back the result. This works consistently across vendors, with capability checks applied to the exact execution route before the request is sent upstream.
Define tools
Tools are defined as function objects with a name, description, and a JSON Schema for the parameters.
Send a request with tools
Handle the response
When the model calls a tool, the response contains a tool_use content block with finish_reason: "tool_use".
Send tool results
After executing the function, send the result back with a tool_result input to continue the conversation.
Tool choice
Control whether and how the model uses tools.
OpenAI SDK
Tool calling works through the OpenAI SDK with a simple update of changing the base url and API key.
AI SDK (Vercel)
Tool calling works with the Vercel AI SDK using the tool() helper and Zod schemas.
FAQ
Which models support tool calling?
Use GET /v1/models and inspect vendors.<vendor>.capabilities.supports_tool_calling for the exact route you plan to use.
Can the model call multiple tools at once?
Yes. The response may contain multiple tool_use content blocks. Send a tool_result for each one before continuing the conversation.
Does Gateway validate tool parameters?
No. Tool parameter schemas are passed directly to the provider. Validation is handled by the model and your application.
Capability checks
Gateway validates tool support against the exact vendor route that will serve the request. Use GET /v1/models and inspect vendors.<vendor>.capabilities.supports_tool_calling and vendors.<vendor>.capabilities.supports_tool_choice when deciding whether to send tools or a specific tool_choice value.