File: infer-ui-tool.md | Updated: 11/15/2025
Menu
v5 (Latest)
AI SDK 5.x
Model Context Protocol (MCP) Tools
Copy markdown
=====================================================================================
Infers the input and output types of a tool.
This type helper is useful when working with individual tools to ensure type safety for your tool inputs and outputs in UIMessages.
import { InferUITool } from 'ai';
Tool
The tool to infer types from.
A type that contains the inferred input and output types of the tool.
The resulting type has the shape:
{ input: InferToolInput<TOOL>; output: InferToolOutput<TOOL>;}
import { InferUITool } from 'ai';import { z } from 'zod';
const weatherTool = { description: 'Get the current weather', parameters: z.object({ location: z.string().describe('The city and state'), }), execute: async ({ location }) => { return `The weather in ${location} is sunny.`; },};
// Infer the types from the tooltype WeatherUITool = InferUITool<typeof weatherTool>;// This creates a type with:// {// input: { location: string };// output: string;// }
InferUITools
ToolUIPart
On this page
Deploy and Scale AI Apps with Vercel.
Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.
Trusted by industry leaders: