cloudflare / cloudflare/ai

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

Open
#517 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
1.2k
Forks
345
Avg merge
13h 31m
Merged PRs (30d)
1

Description

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!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.