Skip to content

How to enable Google Search tool when using a Unified Provider? #517

@IamFive

Description

@IamFive

Hi,

I can currently enable Google Search using the standard GoogleGenerativeAI provider like this:

const google = createGoogleGenerativeAI()
const { text } = await generateText({
  model: aigateway(google('gemini-2.5-flash')),
  prompt: 'hello world',
  tools: {
    google_search: google.tools.googleSearch({}),
  },
})

However, I'm trying to achieve the same functionality while using a unified provider with a dynamic router. Since the tools are usually provider-specific, I'm not sure how to inject the Google Search tool into a unified model instance.

Current Implementation:

const unified = createUnified()
const model = aigateway(unified('dynamic/router'))

const { text } = await generateText({
  model,
  prompt: 'hello world',
  // How to enable google_search here?
})

Could you please provide an example of how to implement this? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions