Gemini Tool Retrieval API Guide (2026): Defer Tool Schemas and Cut Prompt Tokens
On November 19, 2026, the Gemini API release notes added tool retrieval in preview. The feature lets the model search your tool library and load only the function schemas it needs for a given turn. If your agent sends 30 or 40 function declarations on every call, this is the change to look at this week.
Key takeaways
- Gemini tool retrieval entered preview in the Gemini API release notes dated November 19, 2026.
- Tool retrieval runs only on the Interactions API with the
v1betaAPI version. ThegenerateContentmethod does not support it. - It works with Gemini 3.6 and later, including every Gemini 4 model such as
gemini-4-hydrogenandgemini-4-neon. - Mark tools with
defer_loading: trueand add one{"type": "tool_search"}entry per request. - Gemini 4 Neon costs $3.00 per 1M input tokens and $15.00 per 1M output tokens on the paid tier, with a 1,048,576-token context window.
What Tool Retrieval Changes
Every function declaration you send counts as input tokens, and that cost repeats on every request. Google's docs put the problem plainly: a few dozen declarations can consume tens of thousands of tokens per call. Tool selection also gets worse as the list grows.
Tool retrieval fixes this by splitting your tools into two groups. Tools you mark with defer_loading: true stay out of the initial context. The model sees only their names and descriptions. When it needs one, it loads the full parameter schema, calls the function, and continues. The model handles this inside a single API request, so your code only runs the final function_call step.
You have two modes. Server-side retrieval is the default, and you add {"type": "tool_search"} to the tools array. Client-side retrieval sets execution: "client" on the search tool, so your own code runs the lookup and returns matching tools. Server-side is the simpler path. Use client-side if your tool library lives in a database or search index you already run.
Pricing and Model Comparison
Tool retrieval does not add a separate line item on the model price list. You pay for the tokens you send and receive, so the savings depend on how many schemas stay deferred. The table below lists the Gemini 4 prices and a GPT-6.2 Sol reference point, all per 1M tokens on the paid tier.
| Model | Input (USD / 1M) | Output (USD / 1M) | Context window | Source |
|---|---|---|---|---|
Gemini 4 Neon (gemini-4-neon) | $3.00 | $15.00 | 1,048,576 tokens | Gemini API pricing, Nov 18, 2026 |
Gemini 4 Hydrogen (gemini-4-hydrogen) | $1.50 | $7.50 | 1,048,576 tokens | Gemini API pricing and model page |
| GPT-6.2 Sol | $2.00 | $10.00 | 1,050,000 tokens | OpenAI model page |
Here is a rough cost model. Assume 40 declarations at about 400 tokens each. That is about 16,000 input tokens of tool definitions per request before the user message arrives. If retrieval keeps 36 of those 40 deferred and loads 4 on a typical turn, you send far fewer schema tokens. The exact saving depends on your tool set and how often the model needs a deferred tool, so measure it on your own traffic before you budget around it.
| Attribute | Gemini 4 Neon | Gemini 4 Hydrogen |
|---|---|---|
| Input price | $3.00 per 1M | $1.50 per 1M |
| Output price | $15.00 per 1M | $7.50 per 1M |
| Context window | 1,048,576 tokens | 1,048,576 tokens |
| Best fit | Multi-file coding and long agent sessions | Lower-cost Gemini 4 workloads |
Python Example
This example follows the pattern in Google's docs. It declares one search tool and two deferred functions. The model decides which one to load.
from google import genai
client = genai.Client(http_options={"api_version": "v1beta"})
tools = [
{"type": "tool_search"},
{
"type": "function",
"name": "convert_currency",
"description": "Convert an amount from one currency to another.",
"defer_loading": True,
"parameters": {
"type": "object",
"properties": {
"amount": {"type": "number"},
"from_currency": {"type": "string"},
"to_currency": {"type": "string"},
},
"required": ["amount", "from_currency", "to_currency"],
},
},
{
"type": "function",
"name": "get_exchange_rate_history",
"description": "Return historical exchange rates for a currency pair.",
"defer_loading": True,
"parameters": {
"type": "object",
"properties": {
"pair": {"type": "string"},
"days": {"type": "integer"},
},
"required": ["pair", "days"],
},
},
]
interaction = client.interactions.create(
model="gemini-4-hydrogen",
input="Convert 100 USD to EUR.",
tools=tools,
)
for step in interaction.steps:
print(step.type, getattr(step, "name", ""))
Watch the step types in the output. You should see a tool_search_call and a tool_search_result before the function_call. Your code executes only the function_call.
curl Example
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-hydrogen",
"input": "Convert 100 USD to EUR.",
"tools": [
{"type": "tool_search"},
{
"type": "function",
"name": "convert_currency",
"description": "Convert an amount from one currency to another.",
"defer_loading": true,
"parameters": {
"type": "object",
"properties": {
"amount": {"type": "number"},
"from_currency": {"type": "string"},
"to_currency": {"type": "string"}
},
"required": ["amount", "from_currency", "to_currency"]
}
}
]
}'
Multi-Turn Rule That Breaks Agents
The docs include one rule that matters for agent loops. Keep every step the model returns in your history, unchanged. That includes the tool_search_call and tool_search_result steps. Each later request must also send the full tools array, including the tool_search entry and the deferred tools. If you rebuild history from only your own messages and function results, the model loses the context it used to find its tools, and later turns can fail or call the wrong function.
Caveats Before You Ship
- Preview status. Google says the API surface may change before general availability. Pin your SDK version and test after each update.
- Endpoint scope. If your code uses
generateContent, you need to move those calls to the Interactions API first. - Tool descriptions matter more. The model picks deferred tools from their names and descriptions. Vague descriptions will hurt retrieval just as they hurt normal function calling.
- Gateway paths. Routing through a proxy or gateway adds a layer that has to pass
/v1beta/interactionsand the new step types through unchanged.
If you route Gemini calls through KissAPI, send one Interactions request with a tool_search entry before you move production traffic. Confirm that the response contains the tool_search_call step. That one test tells you more than any pricing estimate.
Quick Checks Before You Switch
- Count your current tool tokens with the token counter.
- Estimate the monthly input cost with the API cost calculator, using your real request volume.
- Mark only the tools that a typical turn does not need as
defer_loading: true. Keep the common three or four loaded. - Log the step types and token usage for a week. Compare the input token count against your pre-change baseline.
Final Take
Tool retrieval is a clean fix for large tool sets, and the change is small in code. The real question is whether your agent uses only a handful of tools per turn. If it does, deferred schemas should cut input tokens. If every turn needs all 40 tools, the feature buys you little. Measure first, then switch.
Frequently Asked Questions
Which Gemini models support tool retrieval?
Tool retrieval works with Gemini 3.6 and later models, including every Gemini 4 model such as gemini-4-hydrogen and gemini-4-neon. It runs on the Interactions API with the v1beta API version.
Can I use tool retrieval with generateContent?
No. The generateContent method does not support tool retrieval. Move those calls to the Interactions API first.
How many tool_search entries can one request include?
One. Add a single {"type": "tool_search"} entry, and set defer_loading: true on each tool you want to withhold.
Test Gemini 4 Calls Through One Key
Create a free account at api.kissapi.ai/register and run the Interactions request above against your own tool set.
Start Free