Skip to main content
Use Valyu as a search tool in your Gemini application. Gemini chooses when to retrieve information; your code executes the search and returns the results. You keep control over the model, prompt and user experience.

Install and authenticate

This example uses the Google Gen AI Python SDK and its Interactions API. It replaces the older google-generativeai integration.
Choose a model that supports function calling in your Google account. Get a Valyu key from the platform.

Search from Gemini

Save the following as research.py and run python research.py. The loop allows up to five model responses and retains the interaction ID between tool calls.

Adapt the tool to your product

Set source filters, result limits and date ranges inside the search function so your application owns those constraints. Return the Search response, including success, errors and source URLs, so the model can distinguish a failed request from missing evidence. For a literature feature, start with a specific paper query and inspect the source catalogue. For a company-research feature, state the company and the evidence you need. Source availability depends on the endpoint and your account. Model usage is billed by Google; retrieval is billed by Valyu. The loop limit bounds model-tool rounds, not the total cost or number of parallel calls in a round.

Next steps

Search parameters

Configure sources, result count and returned content.

Run a research task

Use DeepResearch when you want Valyu to run the investigation.

Google function calling

Review the current Interactions API and model requirements.