AI

Gemini API Now Supports Tool Retrieval to Scale Agents Efficiently

Google launches Tool Retrieval in preview, letting agents load tool parameter schemas only when needed to reduce input tokens and latency.

3 min readSource: Google AI Blog

Curated by Kandala Guruprasad. Drafted with AI and checked against the source.

Gemini API Now Supports Tool Retrieval to Scale Agents Efficiently

TL;DR

  • Tool Retrieval is now available in preview in the Gemini Interactions API, allowing agents to load tool parameter schemas on demand rather than sending the entire tool library with every request
  • The feature reduces input token counts and latency by keeping tools on standby and retrieving only the schemas needed for the current task, while the model still sees tool names and descriptions
  • You enable Tool Retrieval by adding a tool_search tool and setting defer_loading: true on tools in your requests; the model searches for and loads schemas within a single API call
  • Tool Retrieval works with Gemini 3.6 and later models, including all Gemini 4 models, with no separate pricing charge beyond standard input and output token rates
Availability
Preview in Interactions API
Supported Models
Gemini 3.6 and later
Pricing
No separate charge

What Tool Retrieval Does

Tool Retrieval helps developers manage large tool libraries by loading parameter schemas only when an agent needs them, rather than sending every tool's full details on every request. When an agent connects to dozens or hundreds of tools, including complete parameter schemas for all of them in each prompt increases input token counts, adds latency, and can reduce tool-selection accuracy as the candidate list grows. The feature keeps the full tool library available on standby, allowing the model to see the name and description of every tool but keeping detailed parameter schemas out of context until required.

How to Enable Tool Retrieval

Enabling Tool Retrieval requires minimal code changes. You add a tool_search tool to your request and set defer_loading: true on the tools you want to defer. The model still knows what tools are available through their names and descriptions. When the model needs a specific tool, it asks for it by name, the API loads the full schema, and the model calls the function—all within the same request without additional round trips to your server.

The process is transparent in the API response. The interaction.steps array shows each step: the tool search call, the tool search result with the loaded schema, and the final function call. This makes debugging easier when you need to inspect which tools the model considered or verify tool names and descriptions are correct.

There is no separate index to build or host. Gemini runs the search server-side, so your only code changes are adding the tool_search tool and the defer_loading flag. You can keep your most-used tools loaded up front and defer only the long tail of less frequent tools.

python
from google import genai
client = genai.Client()
tools = [
{"type": "tool_search"},
{
"type": "function",
"name": "issue_refund",
"description": "Refund an order to the original payment method.",
"defer_loading": True,
"parameters": {
"type": "object",
"properties": {
"order_id": {"type": "string"},
"amount": {"type": "number"},
},
"required": ["order_id", "amount"],
},
},
]
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="Order A-1042 arrived damaged. Please refund 40 dollars.",
tools=tools,
)

Compatibility and Performance

Tool Retrieval works seamlessly with prefix caching, a performance optimization for multi-turn conversations. Deferred schemas remain out of the prompt prefix, and newly loaded schemas are added later in the conversation, so the cached prefix remains consistent from turn to turn, maintaining its efficiency benefits.

The feature also integrates with remote MCP (Model Context Protocol) servers. By setting defer_loading: true on an mcp_server tool, every tool that server exposes is loaded on demand. This allows you to connect a large server without declaring each of its tools individually.

Client-Side Tool Retrieval Option

For developers who maintain their own tool registry, embedding index, or per-user permission filters, Tool Retrieval supports client-side execution. You declare the tool_search with "execution": "client" and define your search parameters. This approach adds one round trip per search because your application runs the lookup, but it allows you to expose new tools mid-conversation when a user connects an integration, without declaring tools upfront.

Pricing and Model Support

Tool Retrieval has no separate charge. Input and output tokens are billed at standard rates for the model you call. Adding tool_search introduces a small, fixed block of input tokens, and each schema the model loads is billed as input for the rest of the conversation, the same as a tool declared up front. You save tokens when the deferred schemas you never load outweigh the ones you do retrieve, which is typically the case for large libraries. Google recommends measuring the impact against your own traffic patterns to verify cost savings.

The feature works with Gemini 3.6 and later models, including all Gemini 4 models, within the Interactions API.

Source

Google AI Bloghttps://blog.google/innovation-and-ai/technology/developers-tools/gemini-api-tool-retrieval/

AI-assisted, verified against the source. This post was drafted with AI from the primary source linked above and checked automatically against it. For anything you depend on, read the original.

  • #geminiapi
  • #toolretrieval
  • #agents
  • #inputtokens
  • #apidevelopment

More in AI