Skip to main content
The @langchain/google package supports Gemini’s built-in tools, which provide capabilities like web search grounding, code execution, URL context retrieval, and more. These tools are passed as Gemini-native objects to ChatGoogle via bindTools() or the tools call option.
You cannot mix Gemini native tools (Google Search, Code Execution, etc.) with standard LangChain tools (Zod-based function tools) in the same request. See the ChatGoogle page for standard tool calling usage.
The googleSearch tool grounds model responses with real-time Google Search results. This is useful for questions about current events or specific facts.
You can optionally filter search results to a specific time range:
The googleSearchRetrieval tool is maintained for backwards compatibility, but googleSearch is preferred.
For more information, see Google’s Grounding with Google Search documentation.

Code execution

The codeExecution tool allows Gemini to generate and run Python code to solve complex problems. The model writes the code, executes it, and returns the results.
The response includes both the generated code and its execution result in the contentBlocks field:
For more information, see Google’s Code Execution documentation.

URL context

The urlContext tool allows Gemini to fetch and use content from URLs to ground its responses.
For more information, see Google’s URL Context documentation.

Google Maps

The googleMaps tool grounds responses with geospatial context from Google Maps. This is useful for place-related queries.
You can enable a widget context token for rendering a Google Maps widget:
For more information, see Google’s Google Maps grounding documentation. The fileSearch tool performs semantic retrieval from file search stores. Files must first be imported using the Gemini File API.
Configuration options:
  • fileSearchStoreNames (required) — the names of the file search stores to retrieve from
  • metadataFilter (optional) — metadata filter to apply to the retrieval
  • topK (optional) — the number of semantic retrieval chunks to return
For more information, see Google’s File Search documentation.

Computer use

The computerUse tool enables Gemini to interact with a browser environment. The model can view screenshots and perform actions like clicking, typing, and scrolling.
Configuration options:
  • environment (required) — the environment being operated (e.g. "ENVIRONMENT_BROWSER")
  • excludedPredefinedFunctions (optional) — predefined functions to exclude from the action space
For more information, see Google’s Computer Use documentation.

MCP servers

The mcpServers field allows Gemini to connect to remote MCP (Model Context Protocol) servers. Unlike other native tools, MCP servers are specified as an array on the tool object.
For more information, see Google’s MCP documentation.

Vertex AI Search data store

If you are using Vertex AI (platformType: "gcp"), you can ground responses using a Vertex AI Search data store.
For more information, see Google’s Vertex AI Search grounding documentation.