ai-sdk-provider icon indicating copy to clipboard operation
ai-sdk-provider copied to clipboard

How to enable URL Context and Google Search Grounding using this SDK?

Open adyingdeath opened this issue 6 months ago • 3 comments

The Gemini models support URL Context and Google Search Grounding features, which are very useful. However, after searching online and trying various parameters like extraBody, I still can't figure out how to enable these features through this SDK.

For example, when I provide a Reddit post URL and ask a question about its content, it works in Google AI Studio but fails here—indicating these features aren't properly enabled in my implementation.

I've tried the following approaches without success:

const { text } = await generateText({
  model: openrouter(GEMINI_MODEL, {
    extraBody: {
      tools: [{ urlContext: {} }]
    }
  }),
  prompt: "xxx"
});
const { text } = await generateText({
  model: openrouter(GEMINI_MODEL, {
    extraBody: {
      config: {
        tools: [{ urlContext: {} }]
      }
    }
  }),
  prompt: "xxx"
});

Could you please provide guidance on the correct way to enable these features? Any documentation references or working examples would be greatly appreciated.

adyingdeath avatar Jun 27 '25 03:06 adyingdeath

cc @yogasanas

louisgv avatar Jul 23 '25 05:07 louisgv

is there any update on this issue ?

nivekithan avatar Aug 05 '25 07:08 nivekithan

same problem!

chyyynh avatar Nov 07 '25 18:11 chyyynh

Facing the same issue as well. Any updates on this?

ZJTAN97 avatar Dec 15 '25 00:12 ZJTAN97