News · Automation

Google's Gemini API Tool Retrieval cuts token costs for large agent tool libraries

Now in preview in the Interactions API, Tool Retrieval loads function schemas on demand so agents can scale to hundreds of tools without bloating every prompt.

By Emonarc Editorial Team4 min read
A risograph-style overhead view of dimmed tool icons on a desk, with one bright tool expanding toward a tablet, illustrating selective on-demand retrieval.

Google has launched Tool Retrieval in the Gemini API, giving developers a way to manage large tool libraries without sending every parameter schema in every request. The feature is now in preview in the Interactions API and is aimed at agents that connect to dozens or hundreds of functions, where full tool definitions inflate input token counts, add latency, and degrade tool-selection accuracy.

How on-demand loading works

Turning on Tool Retrieval requires two changes: adding a tool_search tool to the request and setting defer_loading: true on the tools the developer wants to hold back. The model still sees the name and description of every deferred tool, so it knows what is available, but the parameter schemas stay out of context until they are needed.

When the model decides it 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. Google says there is no index to build or host — the search runs on Google's servers. Developers can keep their most-used tools loaded up front and defer the long tail.

All three steps — the search call, the result, and the function call — appear in interaction.steps, which Google says makes it easier to debug which tools the model considered when troubleshooting tool names or descriptions.

Server-side and client-side retrieval options

Tool Retrieval supports two execution modes. In the default server-side mode, Gemini handles the search internally with no extra round trips.

For teams that maintain their own tool registries, embedding indexes, or per-user permission filters, Google offers a client-side option. Developers declare the tool_search with "execution": "client" and define their own search parameters. The model emits a function call for the search tool, and the developer's application runs the lookup and returns matching schemas. Client-side retrieval adds one round trip per search, but tools do not need to be declared upfront — so new integrations can be exposed mid-conversation when a user connects one.

Tool Retrieval also works with remote MCP servers in the Gemini API. Setting defer_loading: true on an mcp_server tool means every tool that server exposes is loaded on demand, so developers can connect a large server without listing its tools individually.

Token economics and model support

According to Google, Tool Retrieval carries no separate charge. Input and output tokens are billed at the standard rates for the model being called. Enabling tool_search adds a small, fixed block of input tokens, and each schema the model loads is billed as input for the remainder of the conversation, the same as a tool declared up front.

The savings come when the schemas that are never loaded outweigh the ones that are — which Google says is the usual case for large libraries. The company recommends measuring the trade-off against your own traffic.

Tool Retrieval also plays well with prefix caching. Because deferred schemas stay out of the start of the prompt and loaded schemas are added later in the conversation, the cached prefix remains stable from turn to turn.

The feature works with Gemini 3.6 and later models, including all Gemini 4 models, in the Interactions API. For context on Google's recent model cadence, the company has been shipping new Gemini variants frequently, including Gemini 4 Neon and Gemini 4 Carbon with agent swarm preview.

Practical implications for developers

For freelancers and small teams building AI agents on the Gemini API, Tool Retrieval removes a real scaling constraint. As an agent accumulates integrations — payment processing, CRM lookups, calendar management, file operations — the tool library grows and so does the cost of every API call. Loading schemas on demand directly addresses that cost growth.

Teams already using automation platforms like n8n or Make to orchestrate workflows may find that Tool Retrieval makes it more practical to build agents that call those same workflows selectively, without declaring every possible automation upfront.

The client-side retrieval option is particularly relevant for multi-tenant applications where available tools differ per user or per permission level. Instead of filtering tools before each request, the agent can search the user's authorized registry at runtime.

For broader context on how the AI automation landscape is evolving, see our ranked guide to the best AI automation tools.

What to watch

Tool Retrieval is in preview, which means the API surface and behavior could change before a general release. Google points developers to its documentation for the full setup guide with examples, and to Discord for sharing feedback with the team.

The MCP server integration is worth watching closely. As the Model Context Protocol ecosystem grows, the ability to connect a large remote server without enumerating every tool could simplify how agents tap into third-party services. If Google extends Tool Retrieval beyond the Interactions API to other Gemini endpoints, that would broaden its usefulness further.

For now, developers building agents with large tool libraries on Gemini 3.6 or later can start testing today and measure the token savings against their own usage patterns.

Frequently asked questions

What is Tool Retrieval in the Gemini API?

Tool Retrieval lets agents keep a full tool library on standby and load parameter schemas only when the current task needs them, reducing input token counts and latency. It is available in preview in the Interactions API.

How do you enable Tool Retrieval?

Add a tool_search tool to your request and set defer_loading: true on the tools you want to hold back. The model sees each deferred tool's name and description but loads the full parameter schema only when it needs that tool.

Does Tool Retrieval cost extra?

There is no separate charge. Tokens are billed at standard model rates. Enabling tool_search adds a small fixed block of input tokens, and each loaded schema is billed as input for the rest of the conversation. You save tokens when the schemas you never load outweigh the ones you do.

Which Gemini models support Tool Retrieval?

Tool Retrieval works with Gemini 3.6 and later models, including all Gemini 4 models, in the Interactions API.

Sources

  1. Google AI: Introducing Tool Retrieval in the Gemini API

The daily AI brief. 5 minutes, free.

What shipped, what changed in pricing, and the tools actually worth paying for.

No spam. Unsubscribe in one click.