Is it possible to use search grounding with OpenAI api?

When doing:

{
  "model": "gemini-2.5-flash-preview-05-20",
  "reasoning_effort": "medium",
  "messages": [
    {
      "role": "user",
      "content": "prompt"
    }
  ],
  "tools": [
    {
      "googleSearch": {}
    }
  ]
}

I get:

"data": [
    {
      "error": {
        "code": 400,
        "message": "Invalid JSON payload received. Unknown name \"googleSearch\" at 'tools[0]': Cannot find field.",
        "status": "INVALID_ARGUMENT",
        "details": [
          {
            "@type": "type.googleapis.com/google.rpc.BadRequest",
            "fieldViolations": [
              {
                "field": "tools[0]",
                "description": "Invalid JSON payload received. Unknown name \"googleSearch\" at 'tools[0]': Cannot find field."
              }
            ]
          }
        ]
      }
    }
  ]

Am I doing something wrong or is it just not possible with the OpenAI api?

Hi @John_Twelve

Welcome to the dev community.

Search grounding is a server tool for consumption with Gemini API and thus cannot be used with OpenAI API. That said OpenAI API has it own web search tool.

I’m curious about what you’re building.

2 Likes

Hello!

Welcome to the Forum!

As @sps correctly mentioned Grounding with Google Search is a feature in Gemini API and Google AI Studio, hence cannot be used with other APIs. Thank you and happy coding.

2 Likes

Thanks for the clarification.

1 Like

I’d also like to be able to do this via the OpenAI compatibility API. Perhaps it could be supported via the extra_body config at some point?