Web search and fetch
Access the live internet directly from your prompt. In this guide, youâll learn how to search for up-to-date documentation, fetch deep context from specific URLs, and apply that knowledge to your code.
Prerequisites
Section titled âPrerequisitesâ- Gemini CLI installed and authenticated.
- An internet connection.
How to research new technologies
Section titled âHow to research new technologiesâImagine you want to use a library released yesterday. The model doesnât know about it yet. You need to teach it.
Scenario: Find documentation
Section titled âScenario: Find documentationâPrompt:
Search for the 'Bun 1.0' release notes and summarize the key changes.
Gemini uses the google_web_search tool to find relevant pages and synthesizes
an answer. This âgroundingâ process ensures the agent isnât hallucinating
features that donât exist.
Prompt: Find the documentation for the 'React Router v7' loader API.
How to fetch deep context
Section titled âHow to fetch deep contextâSearch gives you a summary, but sometimes you need the raw details. The
web_fetch tool lets you feed a specific URL directly into the agentâs context.
Scenario: Reading a blog post
Section titled âScenario: Reading a blog postâYou found a blog post with the exact solution to your bug.
Prompt:
Read https://example.com/fixing-memory-leaks and explain how to apply it to my code.
Gemini will retrieve the page content (stripping away ads and navigation) and use it to answer your question.
Scenario: Comparing sources
Section titled âScenario: Comparing sourcesâYou can even fetch multiple pages to compare approaches.
Prompt:
Compare the pagination patterns in https://api.example.com/v1/docs and https://api.example.com/v2/docs.
How to apply knowledge to code
Section titled âHow to apply knowledge to codeâThe real power comes when you combine web tools with file editing.
Workflow:
- Search: âHow do I implement auth with Supabase?â
- Fetch: âRead this guide: https://supabase.com/docs/guides/auth.â
- Implement: âGreat. Now use that pattern to create an
auth.tsfile in my project.â
How to troubleshoot errors
Section titled âHow to troubleshoot errorsâWhen you hit an obscure error message, paste it into the chat.
Prompt:
I'm getting 'Error: hydration mismatch' in Next.js. Search for recent solutions.
The agent will search sources such as GitHub issues, StackOverflow, and forums to find relevant fixes that might be too new to be in its base training set.
Next steps
Section titled âNext stepsâ- Explore File management to see how to apply the code you generate.
- See the Web search tool reference for citation details.
- See the Web fetch tool reference for technical limitations.