Can't use OpenAI WebSearch tool

Hi there. I can't seem to use OpenAI's WebSearch tool from the AI SDK. I get this error (cut off due to Discord's text limit):
...
Types of property 'inputSchema' are incompatible.
Type 'FlexibleSchema<{}>' is not assignable to type 'FlexibleSchema<any>'.
Type 'Schema<{}>' is not assignable to type 'FlexibleSchema<any>'.
Type 'Schema<{}>' is not assignable to type 'Schema<any>'.
Property '[validatorSymbol]' is missing in type 'Schema<{}>' but required in type 'Validator<any>'.ts(2322)
index.d.ts(103, 5): '[validatorSymbol]' is declared here.
...
Types of property 'inputSchema' are incompatible.
Type 'FlexibleSchema<{}>' is not assignable to type 'FlexibleSchema<any>'.
Type 'Schema<{}>' is not assignable to type 'FlexibleSchema<any>'.
Type 'Schema<{}>' is not assignable to type 'Schema<any>'.
Property '[validatorSymbol]' is missing in type 'Schema<{}>' but required in type 'Validator<any>'.ts(2322)
index.d.ts(103, 5): '[validatorSymbol]' is declared here.
Essentially some mismatched types by the looks of it. Here's the code:
import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";

export const researchAgent = new Agent({
...
tools: {
web_search: openai.tools.webSearch({}),
},
});
import { openai } from "@ai-sdk/openai";
import { Agent } from "@mastra/core/agent";

export const researchAgent = new Agent({
...
tools: {
web_search: openai.tools.webSearch({}),
},
});
Where web_search: openai.tools.webSearch({}) gives the error. Here are the versions I'm on (the latest, as far as I know):
"@ai-sdk/openai": "^2.0.52",
"@mastra/core": "^0.21.1",
"ai": "^5.0.76",
"zod": "^4.1.12"
"@ai-sdk/openai": "^2.0.52",
"@mastra/core": "^0.21.1",
"ai": "^5.0.76",
"zod": "^4.1.12"
Is this the proper way to use the web search tool?
1 Reply
Mastra Triager
GitHub
[DISCORD:1428923777575686387] Can't use OpenAI WebSearch tool · Is...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1428923777575686387 Hi there. I can&#39;t seem to use OpenAI&#39;s WebSearch tool from the AI SDK. I get t...

Did you find this page helpful?