Skip to main content

03 - Gemini: Functions, JSON and Google Search

The four-step function calling loop, the JSON schema limits the server ignores and the cost of grounding with Google Search, with three scripts.

What do you think about this article?

03 - Gemini: Functions, JSON and Google Search
Google Gemini for Developersfedericocalo.dev

At a Glance

The four-step function calling loop, the JSON schema limits the server ignores and the cost of grounding with Google Search, with three scripts.

Short answer. A model on its own writes text; to make it do something (read a calendar, query a database, search the web) the Gemini API offers three mechanisms. Function calling: you declare the functions, the model replies with a function_call step that contains a name and arguments, you run the function and send the result back. Structured output: you ask for JSON that conforms to a schema, but eight schema keywords (among them minLength, maxLength and uniqueItems) are ignored by the server without an error, so the final validation stays yours. Grounding with Google Search: the model searches the web and cites its sources; the first 5,000 searches per month are free, then you pay 14 dollars per 1,000, and the default limit is 1,500 requests per day per project. The pages for gemini-4-hydrogen, gemini-4-argon and gemini-3.8-flash declare all three capabilities (pages opened on 13 November 2026).

Third article in the series: from the second you take the key, the first call and the rule that tools and instructions must be redeclared at every turn. I am not affiliated with Google. No listing calls the API, because I used no keys and no accounts: the three call schemas are "to adapt" and checked only for syntax, and the three scripts that were run check declarations, arguments, schemas and costs, with a fake model that I declare as such. The Python SDK used to check the names is version 3.3.0, published on 12 November 2026.

The function calling loop, step by step

Think of a function that adjusts the living-room lamp. The loop has four moments, and the second is the one that surprises beginners: the model executes nothing. First, you declare the function as a tool of type function, with name, description and parameters in the form of a schema. Second, you call the model passing tools and look among the steps of the response for the one of type function_call, which has id, name and arguments. Third, you run the function in your own code. Fourth, you send the result back with a function_result element (the keys are name, call_id with the id of the step you received and result, a list of text blocks) together with previous_interaction_id and the tools, redeclared. The identifiers in the example are Italian and are kept as in the original: imposta_luce is "set light", livello is "level", tono is "tone", and its values freddo, neutro and caldo mean cool, neutral and warm; the prompt asks to lower the lights to a romantic level.

import json
from google import genai

MODELLO = "gemini-4-hydrogen"
client = genai.Client()                       # key from GEMINI_API_KEY

imposta_luce = {
    "type": "function",
    "name": "imposta_luce",
    "description": "Imposta luminosita e tono della lampada del soggiorno.",
    "parameters": {
        "type": "object",
        "properties": {
            "livello": {"type": "integer", "minimum": 0, "maximum": 100},
            "tono": {"type": "string", "enum": ["freddo", "neutro", "caldo"]},
        },
        "required": ["livello", "tono"],
    },
}

prima = client.interactions.create(
    model=MODELLO,
    input="Abbassa le luci a un livello romantico.",
    tools=[imposta_luce],
)
chiamata = next((s for s in prima.steps if s.type == "function_call"), None)
if chiamata is None:                           # with tool_choice "auto" the model may answer in words
    print(prima.output_text)
else:
    # 1) validate chiamata.arguments against the schema; 2) ask for confirmation if the function writes
    risultato = {"livello": chiamata.arguments["livello"], "tono": chiamata.arguments["tono"]}
    finale = client.interactions.create(
        model=MODELLO,
        input=[{
            "type": "function_result",
            "name": chiamata.name,
            "call_id": chiamata.id,
            "result": [{"type": "text", "text": json.dumps(risultato)}],
        }],
        tools=[imposta_luce],                  # redeclared: it applies only to this interaction
        previous_interaction_id=prima.id,
    )
    print(finale.output_text)

It is a schema to adapt, not executed: it needs a key. The shape is that of the "Function calling" page (steps 1-4) and the file passes the syntax check. In SDK 3.3.0 the types FunctionCallStep (fields arguments, id, name, type) and FunctionResultStepParam (call_id, result, name, type and is_error) exist; on is_error the page does not say what the model does with it, so in the text of the error you write the cause in words. Two lines matter more than the others. next(..., None) handles the case in which, with the default mode, the model answers in words instead of calling the function: without the fallback value, next would raise StopIteration. And tools=[imposta_luce] in the second call is not redundant: if you remove it, the model no longer sees the function.

The following script tests what lies between step 2 and step 4: is the declaration well formed? Do the proposed arguments respect the schema? Does the function write to the world, and so need a confirmation? The model's "steps" are fake, written by me to trigger each check; the body of step 4 has the shape from the page. Note that the errors accumulate in the same message, so you learn everything that is wrong in one go.

"""The function calling loop, checked locally.
The "model" is a FAKE: the function_call steps are built by me to exercise the checks.
Shape of the declaration and of function_result: Function calling page (2026-11-13)."""
import json
import re

SET_LIGHT = {
    "type": "function",
    "name": "imposta_luce",
    "description": "Imposta luminosita e tono della lampada del soggiorno.",
    "parameters": {
        "type": "object",
        "properties": {
            "livello": {"type": "integer", "minimum": 0, "maximum": 100},
            "tono": {"type": "string", "enum": ["freddo", "neutro", "caldo"]},
        },
        "required": ["livello", "tono"],
        "additionalProperties": False,
    },
}
WRITES = {"imposta_luce": True}          # a function that changes something in the world


def check_declaration(d):
    errors = []
    if d.get("type") != "function":
        errors.append("type must be 'function'")
    if not re.fullmatch(r"[A-Za-z_][A-Za-z0-9_]*", d.get("name", "")):
        errors.append("name: only letters, digits and underscores")
    if not d.get("description"):
        errors.append("description is missing")
    p = d.get("parameters", {})
    if p.get("type") != "object":
        errors.append("parameters.type must be 'object'")
    missing = set(p.get("required", [])) - set(p.get("properties", {}))
    if missing:
        errors.append(f"required names fields that do not exist: {sorted(missing)}")
    return errors


TYPES = {"integer": int, "string": str, "number": (int, float), "boolean": bool, "array": list, "object": dict}


def check_arguments(schema, args):
    errors = []
    props = schema.get("properties", {})
    for r in schema.get("required", []):
        if r not in args:
            errors.append(f"{r} is missing")
    for name, value in args.items():
        if name not in props:
            if schema.get("additionalProperties") is False:
                errors.append(f"unexpected field: {name}")
            continue
        s = props[name]
        expected = TYPES[s["type"]]
        if isinstance(value, bool) and s["type"] in ("integer", "number") or not isinstance(value, expected):
            errors.append(f"{name}: type {type(value).__name__}, expected {s['type']}")
            continue
        if "enum" in s and value not in s["enum"]:
            errors.append(f"{name}: {value!r} is not among {s['enum']}")
        if "minimum" in s and value < s["minimum"]:
            errors.append(f"{name}: {value} below the minimum {s['minimum']}")
        if "maximum" in s and value > s["maximum"]:
            errors.append(f"{name}: {value} above the maximum {s['maximum']}")
    return errors


def run(step, confirm):
    if step["name"] != SET_LIGHT["name"]:
        return None, f"unknown function: {step['name']}"
    errors = check_arguments(SET_LIGHT["parameters"], step["arguments"])
    if errors:
        return None, "; ".join(errors)
    if WRITES[step["name"]] and not confirm(step):
        return None, "denied by the user"
    return {"livello": step["arguments"]["livello"], "tono": step["arguments"]["tono"]}, None


def step_four(step, result, previous_id):
    """Body of the request that sends the result back (shape from the Function calling page, step 4)."""
    return {
        "model": "gemini-4-hydrogen",
        "input": [{"type": "function_result", "name": step["name"], "call_id": step["id"],
                   "result": [{"type": "text", "text": json.dumps(result)}]}],
        "tools": [SET_LIGHT],                  # redeclared: they apply only to this interaction
        "previous_interaction_id": previous_id,
    }


print("declaration:", check_declaration(SET_LIGHT) or "ok")
broken = {"type": "function", "name": "imposta luce", "parameters": {"type": "object", "properties": {}, "required": ["x"]}}
print("broken declaration:", check_declaration(broken))

CASES = [
    {"id": "c1", "name": "imposta_luce", "arguments": {"livello": 25, "tono": "caldo"}},
    {"id": "c2", "name": "imposta_luce", "arguments": {"livello": 250, "tono": "caldo"}},
    {"id": "c3", "name": "imposta_luce", "arguments": {"livello": "25", "tono": "rosa"}},
    {"id": "c4", "name": "imposta_luce", "arguments": {"livello": 25, "tono": "caldo", "durata": 9}},
    {"id": "c5", "name": "apri_porta", "arguments": {}},
]
print("--- steps proposed by the fake model, with confirmation always denied")
for c in CASES:
    print(c["id"], run(c, confirm=lambda p: False))
print("--- with confirmation granted")
result, error = run(CASES[0], confirm=lambda p: True)
print(result, error)
body = step_four(CASES[0], result, "fake_1")
print(json.dumps({k: body[k] for k in ("input", "previous_interaction_id")}, ensure_ascii=False))
print("tools redeclared:", [t["name"] for t in body["tools"]])

# Output:
# declaration: ok
# broken declaration: ['name: only letters, digits and underscores', 'description is missing', "required names fields that do not exist: ['x']"]
# --- steps proposed by the fake model, with confirmation always denied
# c1 (None, 'denied by the user')
# c2 (None, 'livello: 250 above the maximum 100')
# c3 (None, "livello: type str, expected integer; tono: 'rosa' is not among ['freddo', 'neutro', 'caldo']")
# c4 (None, 'unexpected field: durata')
# c5 (None, 'unknown function: apri_porta')
# --- with confirmation granted
# {'livello': 25, 'tono': 'caldo'} None
# {"input": [{"type": "function_result", "name": "imposta_luce", "call_id": "c1", "result": [{"type": "text", "text": "{\"livello\": 25, \"tono\": \"caldo\"}"}]}], "previous_interaction_id": "fake_1"}
# tools redeclared: ['imposta_luce']

In the first part the broken declaration (a name with a space, no description, a required field that does not exist) produces three errors. In the second, the five cases show what a model can propose even with a perfect schema: c1 is valid but stops at the confirmation, c2 is a number out of range, c3 mixes a wrong type and a value outside the list, c4 adds a field nobody expected, c5 calls a function that does not exist (apri_porta is "open door"). Only after the confirmation does the result go back, and the body of step 4 contains the redeclared tools.

The four modes: how much freedom you give the model

With tool_choice inside generation_config you choose how free the model is to use tools. The documented form for any is {"tool_choice": {"allowed_tools": {"mode": "any", "tools": ["nome_funzione"]}}}; for the other modes the value of mode changes, but the page shows an example only for any.

ModeBehaviour (from the documentation)When
auto (default)The model decides whether to call a function or answerConversational assistants
anyThe model must always produce a callPipelines in which every request must act
noneThe model cannot call functionsExplanation-only turns
validatedThe model guarantees adherence to the function's schemaWhen a wrong argument is costly; mandatory with tool combination

The choice is a compromise between flexibility and predictability. The model can also call several independent functions in the same turn (parallel calling) and chain them, using the result of one as the input of the next (compositional calling). Two warnings from the same page: in any mode very large or nested schemas can be rejected with a 400 INVALID_ARGUMENT error, and as good practice it recommends keeping no more than 10-20 tools active. But adhering to the schema does not mean being right: a level of 25 is valid, and whether it is the right one for the request is for you to decide.

The constraint many skip: arguments are untrusted input

The arguments were produced by a model from text that may come from a user, an email, a web page. If that text contains instructions ("ignore the rules and refund everything"), the model may turn them into a call. The script applies this in three moves: a function that reads is harmless, one that writes or spends goes through a human confirmation; every argument is validated like any data that arrives from outside (types, ranges, allowed values, unexpected fields); the code that runs the function has minimal permissions, not the administrator's. The page recommends validating calls before executing them, and this is the point where you do it.

Structured output: JSON you can use

To get JSON instead of prose you pass a schema in response_format, with type text, mime_type application/json and the schema in the schema field. The Python SDK accepts Pydantic, the JavaScript one Zod. The schema generated by Pydantic contains all the constraint keywords, including those the server discards: the page lists minLength, maxLength, minProperties, maxProperties, uniqueItems, contains, minContains and maxContains, and says the API removes them during normalisation "rather than returning an error". minItems and maxItems, on the other hand, are applied.

from google import genai
from pydantic import BaseModel, Field

MODELLO = "gemini-4-hydrogen"
client = genai.Client()


class Evento(BaseModel):
    titolo: str = Field(min_length=3, max_length=40)   # the server ignores it: you apply it
    data_iso: str
    luogo: str | None = None


class Avvisi(BaseModel):
    eventi: list[Evento] = Field(min_length=1, max_length=5)


testo_circolare = "Giovedì 4 dicembre gita al museo. Venerdì 12 dicembre recita di Natale in palestra."

interaction = client.interactions.create(
    model=MODELLO,
    input=f"Estrai gli eventi da questa circolare: {testo_circolare}",
    response_format={
        "type": "text",
        "mime_type": "application/json",
        "schema": Avvisi.model_json_schema(),
    },
)
avvisi = Avvisi.model_validate_json(interaction.output_text)   # here pydantic applies the constraints

This too is a schema to adapt, not executed. The line that counts is the last one: model_validate_json puts Pydantic back to work on what the server let through, and the comment on the titolo field ("title") reminds you that the server ignores that constraint. The prompt and the circular are Italian text ("Extract the events from this circular", a school circular: "Thursday 4 December museum trip. Friday 12 December Christmas play in the gym."). The following script does not call the model: it builds the same schema, looks for which of the ignored keywords it contains, and tries three synthetic outputs, all valid JSON.

"""What the server ignores in a JSON schema, and what is left to you.
List of constraints not applied: Structured outputs page (2026-11-13).
Requires pydantic (here 2.14.3, which came with google-genai)."""
import json
from datetime import date

from pydantic import BaseModel, Field, ValidationError

IGNORED = {"minLength", "maxLength", "minProperties", "maxProperties", "uniqueItems",
           "contains", "minContains", "maxContains"}
SUPPORTED = {"minItems", "maxItems", "minimum", "maximum", "enum", "required"}


class Evento(BaseModel):
    titolo: str = Field(min_length=3, max_length=40)
    data_iso: str
    luogo: str | None = None


class Avvisi(BaseModel):
    eventi: list[Evento] = Field(min_length=1, max_length=5)


schema = Avvisi.model_json_schema()


def keywords(node):
    if isinstance(node, dict):
        for k, v in node.items():
            yield k
            yield from keywords(v)
    elif isinstance(node, list):
        for v in node:
            yield from keywords(v)


found = set(keywords(schema))
print("ignored by the server:", sorted(found & IGNORED))
print("supported by the server:", sorted(found & SUPPORTED))

ANSWERS = {  # SYNTHETIC outputs, written by me: all of them are valid JSON
    "regular": '{"eventi":[{"titolo":"Gita al museo","data_iso":"2026-12-04","luogo":null}]}',
    "title too long": json.dumps({"eventi": [{"titolo": "x" * 60, "data_iso": "2026-12-04"}]}),
    "impossible date": '{"eventi":[{"titolo":"Recita","data_iso":"2026-02-30"}]}',
}
for name, text in ANSWERS.items():
    try:
        notices = Avvisi.model_validate_json(text)
        for e in notices.eventi:
            date.fromisoformat(e.data_iso)      # the meaning is for you to check
        print(f"{name:20} accepted")
    except ValidationError as err:
        print(f"{name:20} rejected by pydantic:", [(e['loc'], e['type']) for e in err.errors()])
    except ValueError as err:
        print(f"{name:20} rejected by the date check:", err)

# Output:
# ignored by the server: ['maxLength', 'minLength']
# supported by the server: ['maxItems', 'minItems', 'required']
# regular              accepted
# title too long       rejected by pydantic: [(('eventi', 0, 'titolo'), 'string_too_long')]
# impossible date      rejected by the date check: day 30 must be in range 1..28 for month 2 in year 2026

The reading is clear-cut: the schema contains two keywords that the server discards (minLength and maxLength), and three supported ones. The first answer is accepted. The second has a title of sixty characters against a maximum of forty: it is valid JSON, but Pydantic rejects it, and the server would not have stopped it. The third, "2026-02-30", is a well-formed string that is not a date: no schema catches it, and you need the check on the meaning. The page says so too: the output is syntactically correct, but the values must be validated in the application. Very large or nested schemas can be rejected with a 400 error.

Grounding with Google Search: answers with sources, and a cost

You add the tool {"type": "google_search"} and the model decides whether to search, generates the queries and synthesises. In the response you find the steps google_search_call (with the queries executed), google_search_result (with search_suggestions, an HTML snippet to show in the interface) and a text block with annotations of type url_citation, each with url, title, start_index and end_index that link a piece of text to its source. In the listing the prompt is Italian and asks whether there are strikes announced in northern European ports this week.

from google import genai

MODELLO = "gemini-4-hydrogen"
client = genai.Client()

interaction = client.interactions.create(
    model=MODELLO,
    input="Ci sono scioperi annunciati nei porti del Nord Europa questa settimana?",
    tools=[{"type": "google_search"}],
)
for passo in interaction.steps:
    if passo.type == "model_output":
        for blocco in passo.content:
            if blocco.type == "text":
                print(blocco.text)
                for nota in blocco.annotations or []:
                    if nota.type == "url_citation":
                        frase = blocco.text[nota.start_index:nota.end_index]
                        print(f"  [{nota.title}]({nota.url}) -> {frase!r}")

Schema to adapt, not executed: the field names are those of the example on the "Grounding with Google Search" page, and in SDK 3.3.0 the type URLCitation does have end_index, start_index, title, type and url. The interval [start_index:end_index] cuts out of the text the sentence that the source supports, and it is what lets you show the citation next to the right sentence and not at the bottom of the page. Search is not available on the free tier.

The cost, for Gemini 3 and later models, is per search executed: if the model makes two searches to answer, that is two billed uses. The first 5,000 per month are free and shared among all Gemini 3 and later models, then you pay 14 dollars per 1,000, and the default limit is 1,500 requests per day per project; to get more you ask in AI Studio. The script calculates the monthly cost in four cases, with two independent calculations: a formula and a simulation day by day, request by request, and an assert that compares them. I assume two things, because the page does not say them: that the limit counts requests and not searches, and that beyond the limit requests are not served.

"""Cost of search with Google (grounding) for Gemini 3 and later models.
Grounding with Google Search page and pricing page, 2026-11-13:
5,000 free searches per month (shared across models), then 14 dollars per 1,000;
default limit of 1,500 requests per day per project (paid tier)."""
from fractions import Fraction

FREE_PER_MONTH = 5_000
DOLLARS_PER_THOUSAND = 14
DEFAULT_RPD = 1_500


def cost_formula(requests_per_day, searches_per_request, days=30, daily_limit=DEFAULT_RPD):
    served = min(requests_per_day, daily_limit) if daily_limit else requests_per_day
    searches = served * searches_per_request * days
    paid = max(0, searches - FREE_PER_MONTH)
    return served, searches, Fraction(paid * DOLLARS_PER_THOUSAND, 1000)


def cost_simulated(requests_per_day, searches_per_request, days=30, daily_limit=DEFAULT_RPD):
    """Second calculation: day by day, request by request."""
    used, dollars = 0, Fraction(0)
    for _ in range(days):
        today = 0
        for _ in range(requests_per_day):
            if daily_limit and today >= daily_limit:
                break                         # a request over the limit is not served
            today += 1
            for _ in range(searches_per_request):
                used += 1
                if used > FREE_PER_MONTH:
                    dollars += Fraction(DOLLARS_PER_THOUSAND, 1000)
    return today, dollars


CASES = [
    ("1,000 requests/day, 1 search", 1_000, 1, DEFAULT_RPD),
    ("3,000 requests/day, default limit", 3_000, 1, DEFAULT_RPD),
    ("3,000 requests/day, raised limit", 3_000, 1, None),
    ("3,000 requests/day, 2 searches each", 3_000, 2, None),
]


print(f"{'case':46}{'served/day':>15}{'searches/month':>15}{'dollars/month':>14}")
for name, rpd, spr, limit in CASES:
    served, searches, dollars = cost_formula(rpd, spr, daily_limit=limit)
    day, dollars2 = cost_simulated(rpd, spr, daily_limit=limit)
    assert (day, dollars2) == (served, dollars)
    print(f"{name:46}{served:>15,}{searches:>15,}{float(dollars):>14,.2f}")

# Output:
# case                                               served/day searches/month dollars/month
# 1,000 requests/day, 1 search                            1,000         30,000        350.00
# 3,000 requests/day, default limit                       1,500         45,000        560.00
# 3,000 requests/day, raised limit                        3,000         90,000      1,190.00
# 3,000 requests/day, 2 searches each                     3,000        180,000      2,450.00

The second case is the most instructive: with the default limit, 3,000 requests a day do not become 90,000 searches, because the limit cuts them to 1,500 served and the cost stops at 560 dollars; the third case, 1,190 dollars, requires that you have asked for and obtained the increase. The last row shows the effect of two searches per request: the bill goes to 2,450 dollars, because search is paid per search and not per request. These are costs of searches alone, tokens are paid separately. For the usage rules the page refers to the terms: grounded results must be shown together with the search suggestions to the user who asked the question, and Google keeps prompt, context and output of these requests for thirty days, which goes in your privacy notice.

Combining tools: search plus your own functions

The "Combine built-in tools and function calling" page describes a preview feature for Gemini 4 and Gemini 3 models: in the same interaction you can provide {"type": "google_search"} and your own functions, and the model can first search and then call your logic. The page names as a limit the use of validated mode, because auto is not supported when tool context circulation is active. With previous_interaction_id the server handles the id and signature of the steps by itself; in stateless mode you must send both back yourself, exactly as you received them. The page's examples warn that they work with SDKs newer than version 2.0.0: 3.3.0 is.

A combination that seems natural, search plus a tool that writes, is also the most delicate: text arriving from the web enters the model's context and can influence its arguments. For this reason the two rules seen before apply here with more force: validation of the arguments and human confirmation for every function that writes.

Three hypothetical scenarios with real constraints

These are scenarios I built, with no real people or companies, and the only figures are those of the script. First: an order status agent. The model receives "where is my order?" and calls stato_ordine(numero), read-only, on the back office. The number is typed by the customer: the function must check that the order belongs to the authenticated user, otherwise anyone reads other people's orders, and a refund function does not exist without human confirmation. It is the case in which validated makes the most sense, because a wrong argument is costly.

Second: school circulars. A parent passes the text of a circular and receives the events in the Avvisi schema seen above. The risk is relative dates ("next Thursday"): the field is a string and must be checked against the calendar, and the event is shown to the parent for confirmation instead of being entered behind their back. Circulars with pupils' names must not be sent on the free tier, where the content may be used to improve the products.

Third: a logistics operations centre that checks news about strikes along its routes with google_search. With 3,000 requests a day with one search each, the script says 560 dollars a month for searches alone if the limit stays at the default and 1,190 if you have it raised. The system flags, it does not decide: a web page is not a verified source, and rerouting a shipment is not entrusted to a summary. For the audit you keep citations, date and time, in compliance with the thirty-day rule and the conditions on grounded results.

What you can do now

You can declare a function and close the loop in four steps, you know which of the four modes to choose, and you know that arguments must be validated and functions that write must be confirmed. You can ask a model for JSON and you know which schema constraints you must reapply yourself. You can calculate what search costs and why the daily limit changes the bill. In article 4 the one-million-token window, reasoning and the cache change the cost of every call you have just learned to write.

What I have not verified

  • No real call: the three listings with genai.Client() are schemas checked for syntax and type names, not executed.
  • The shape of tool_choice for validated: the page shows an example only for any.
  • Whether the limit of 1,500 per day counts requests or searches, and what happens beyond it: in the script they are declared assumptions.
  • The function calling performance of one model compared with another: I have no measurements and I write none.

Here too these are points where a key is needed to confirm. If before going into production you make a single test, make it on the daily limit and on validated mode: they are the two things that change cost and behaviour, and that can be only partly understood from the documentation.

The series

  1. Gemini for Developers: Models and Pricing
  2. Gemini API: key, SDK and Interactions API
  3. This article: functions, JSON and Google Search.
  4. Gemini: 1M-token context, thinking, caching
  5. Gemini API: tiers, limits and data privacy
  6. After Gemini CLI: Antigravity and gemini-api

Function calling is the mechanism on which the Model Context Protocol rests: if you want to expose your tools to several applications, read the introduction to MCP and how to connect Claude Code to external tools with an MCP server.

Frequently asked questions

Does the model really run the function?

No. The model proposes a call, with name and arguments, in a function_call step. You run the function, in your own code, and send the result back with a function_result. That is why the arguments must be validated like any external input.

Is a JSON schema enough to guarantee correct data?

No. The server ignores minLength, maxLength, minProperties, maxProperties, uniqueItems, contains, minContains and maxContains, and valid JSON can contain wrong values. Validate the output with Pydantic or Zod and check the meaning, for example that a date exists.

How much does grounding with Google Search cost?

For Gemini 3 and later models every search executed is paid: 5,000 per month are free and shared among the models, then 14 dollars per 1,000, with a default limit of 1,500 requests per day per project. On the free tier search is not available.

Sources

Commenti

Caricamento commenti...

Sign in to comment

New articles and tools on Telegram too

The Telegram channel flags the site's new articles and tools.

Did you like this article?

Explore other content on the blog or discover my projects