Google Code Execution tool
Google models can generate and execute Python code via the Code Execution tool. Enable it by adding the `code_execution` tool: `const { text, toolCalls, toolResults } = await generateText({ model: google('gemini-2.5-pro'), tools: { code_execution: google.tools.codeExecution({}) }, prompt: 'Use python to calculate the 20th fibonacci number.' });`
Google Search grounding tool
Google models have access to latest information using Google Search grounding via the `google_search` tool. Example: `const { text, sources, providerMetadata } = await generateText({ model: google('gemini-2.5-flash'), tools: { google_search: google.tools.googleSearch({}) }, prompt: 'List the top 5 San Francisco news from the past week. You must include the date of each article.' });`
Google Search tool configuration options
The `googleSearch` tool accepts optional configuration: searchTypes object (with webSearch and/or imageSearch, pass {} to enable; webSearch is default) and timeRangeFilter object (requires startTime and endTime in ISO 8601 format).
Google Search tool grounding metadata fields
When Google Search grounding is enabled, grounding metadata includes: webSearchQueries (string[] | null), searchEntryPoint (object with renderedContent | null), groundingSupports (array with segment, groundingChunkIndices, confidenceScores | null).
Google File Search tool
The File Search tool lets Gemini retrieve context from indexed documents in File Search stores. Example: `const { text, sources } = await generateText({ model: google('gemini-2.5-pro'), tools: { file_search: google.tools.fileSearch({ fileSearchStoreNames: ['projects/my-project/locations/us/fileSearchStores/my-store'], metadataFilter: 'author = "Robert Graves"', topK: 8 }) }, prompt: 'Summarise the key themes of I, Claudius.' });`
Google URL Context tool
Google provides a URL context tool that allows providing specific URLs for the model to analyze directly. You can add up to 20 URLs per request. Supported for Gemini 2.0 Flash models and above. Example: `const { text, sources, providerMetadata } = await generateText({ model: google('gemini-2.5-flash'), prompt: 'Based on the document: https://ai.google.dev/gemini-api/docs/url-context. Answer this question: How many links we can consume in one request?', tools: { url_context: google.tools.urlContext({}) } });`
Google URL Context metadata fields
URL context metadata includes urlMetadata (array of objects with retrievedUrl and urlRetrievalStatus) and groundingMetadata. Possible urlRetrievalStatus values include URL_RETRIEVAL_STATUS_SUCCESS.
Google Maps grounding tool
Google Maps grounding gives models access to Google Maps data for location-aware responses. Example: `const { text, sources, providerMetadata } = await generateText({ model: google('gemini-2.5-flash'), tools: { google_maps: google.tools.googleMaps({}) }, providerOptions: { google: { retrievalConfig: { latLng: { latitude: 34.090199, longitude: -117.881081 } } } satisfies GoogleLanguageModelOptions }, prompt: 'What are the best Italian restaurants within a 15-minute walk from here?' });`
Google Maps grounding metadata structure
When Google Maps grounding is enabled, groundingMetadata includes groundingChunks with maps objects containing uri, title, and placeId fields.
Google Maps grounding supported models
Google Maps grounding is supported on Gemini 2.0 and newer models.
Google Interactions API built-in tools mapping
Provider-defined tools under `google.tools.*` map to Interactions tool descriptors: google.tools.googleSearch → google_search (web/image search grounding), google.tools.codeExecution → code_execution (Python execution), google.tools.urlContext → url_context (fetch URLs), google.tools.fileSearch → file_search (File Search stores), google.tools.googleMaps → google_maps (Maps grounding), google.computer_use → computer_use (browser environment), google.mcp_server → mcp_server (MCP passthrough), google.retrieval → retrieval (Vertex AI Search).
Google Interactions API function tools behavior
Function tools defined with the AI SDK `tool()` helper are translated to Interactions `function` tool descriptors. Other tool kinds emit a warning and are dropped.