MastraM
Mastraโ€ข3mo ago
Microseconds

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.

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({}),
  },
});


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"


Is this the proper way to use the web search tool?
Was this page helpful?