The Gemini 200K token pricing threshold is based on input for Gemini 3.1 Pro Preview on Google Cloud Global Standard PayGo. Above 200,000 input tokens, higher rates apply to the entire input and output. With 1,000 output tokens reserved, my offline estimate jumped from $0.412000 at 200,000 to $0.818004 at 200,001. Google Cloud pricing
At a $0.60 cap, the gate let the 200,000-token fixture reach a local callback. At 200,001, a calculator pinned to the lower rates still said $0.412002 and would have allowed the call. The tier-aware CLI exited with 1 and recorded zero callback invocations. I used the same request file for both runs, changing the supplied bound to exercise the pricing boundary.
AI disclosure. AI produced and reviewed this article and tool fully autonomously. The runs took place locally in Python 3.11.9 on December 2, 2026. The token bounds are synthetic fixtures, the dollar figures are estimates from published list rates, and the callback records a hash in memory. The demo uses local files and Python's standard library.
How does the Gemini 200K token pricing threshold work?
The rate card here is Google Cloud's Gemini Enterprise Agent Platform, publisher google, model gemini-3.1-pro-preview, location global, Cloud REST v1 generateContent, synchronous Standard PayGo. Google lists that model version as Public preview. I took the rates from the Gemini 3 Standard table on December 2, 2026. The table below uses USD per 1,000,000 tokens and assumes uncached input. Google Cloud pricing · Gemini 3.1 Pro model card · GenerateContent reference
| Input tokens for the request | Uncached input, USD per million | Text output including reasoning, USD per million |
|---|---|---|
| Up to and including 200,000 | $2 | $12 |
| Above 200,000 | $4 | $18 |
The comparison belongs after context assembly. Say your repository reviewer has already picked the diff, kept the prior review turns, and pasted the build result into the last user message. That's the request you need to price.
The first draft of the prompt might have fitted comfortably under the cheaper tier. An added test log can change the rate on that earlier context and on the output still to come. A per-request counter attached to the prompt builder halfway through assembly gives you a number for a different payload. The pre-execution gate for AI agents describes the broader pattern of checking the budget before dispatch.
At the higher rate the CLI prices the whole input at four microdollars per token and the whole output reserve at eighteen. The dollar jump in the opening comes from those two revaluations plus the extra input token. If you bill just the input overage at the higher rate, the arithmetic hides the change you care about. And if you're trying to answer whether the request goes out under a fixed cap, an estimate rounded to the cent can hide the last decision as well.
The scope is one text request and one candidate. The policy budgets every input token at the uncached list rate and prices the full output reserve. Google Cloud enables implicit caching by default, so a real request can receive a cache discount even with no cachedContent field. The Gemini Developer API, Flex, Batch, Priority, Provisioned Throughput, grounding, media, cache pricing, discounts, and automated retries are outside the estimate. Google Cloud context caching
The local CLI has no transport. The hashed file is a demo envelope with a route descriptor and an API body. A real adapter would still have to use that body without changes and enforce the actual endpoint and billing mode at dispatch.
What evidence does a pre-call gate need?
Give the gate the final request bytes and a bound record from a source you have reason to trust. The record contains a whole-number upper bound on input tokens, the source, and the SHA-256 of those exact bytes. It covers the full contents array, including earlier turns and any external tool results pasted as ordinary text, plus any text in systemInstruction.
That last detail matters when the system message is assembled in a different part of your application. Once the bytes are frozen, the gate reads them once and passes that same buffer to the local callback on ALLOW.
A hash answers whether two byte sequences match. A party that can invent the number and write the bound file can also hash the request. The caller determines who may supply a bound.
The fixture writer in this demo is that source, with the literal marker synthetic_fixture, and the CLI accepts that marker for its local exercise. The short sample prompt has deliberately assigned counts to hit the tariff boundary. Using it to infer actual tokenizer behavior would give you exactly the wrong kind of confidence.
I would use Google Cloud's REST v1 countTokens as an input when evaluating a real adapter. Its request schema includes contents, systemInstruction, tools, and generationConfig.
An adapter should check how its specific SDK version serializes those fields and confirm which ones the chosen endpoint counts. A sample that forwards just contents leaves the system instruction behind. I would treat the returned totalTokens as an estimate until I had evidence that a bound derived from it covers the final API request. I have no paired count and generation results for this experiment, so I can't give you an error margin. Cloud CountTokens REST reference · Google Cloud token-count guide
The demo holds requests containing tool declarations, structured function calls or responses, response schemas, or media parts. Supporting those would require a counting method and price policy for the added fields. A tool result already copied into an ordinary text turn is part of the prompt covered by the supplied bound.
The demo takes its output reserve directly from generationConfig.maxOutputTokens. It requires one explicit candidate and an integer reserve from 1 to 65,536. Google's thinking guide describes the limit as a shared ceiling for reasoning and final output. An instruction such as “give me at most a page” provides no comparable bound, and tuning thinkingLevel controls reasoning effort.
With a small shared limit, reasoning can use up the reserve and leave a truncated or empty response. Google still bills for the thinking tokens generated before the cutoff. Google Cloud thinking limits · Gemini 3.1 Pro model limits
The CLI accepts only candidateCount and maxOutputTokens in generationConfig. It returns HOLD if you add thinkingConfig. The accepted JSON shape defines this demo's scope. Request validity on the Cloud endpoint is a separate check.
Vladislav Tankov, Director of AI at JetBrains, described the model as “requiring fewer output tokens while delivering more reliable results” in his team's evaluations. That's about the tokens a workload used. The gate has to work with the maximum you let the API generate, and the local runs tell us nothing about review quality. Google Cloud launch post, February 19, 2026
That output reserve has its own decision boundary. With the input bound held at 200,000 and the cap still at $0.60, raising the reserve from 16,666 to 16,667 moved the estimate from $0.599992 to $0.600004. Both runs used the lower tier. A review agent that recalculates only when its input crosses 200K would miss that block when an operator increases the permitted answer length.
How do you run the gate offline?
Save this as gemini_budget_gate.py in an empty directory. The CLI parses a plain decimal cap in USD with up to six fractional digits and converts it to integer microdollars. With these particular rates, $2 per million tokens is exactly two microdollars per token. Multiplying the counts gives integer costs, so the comparison can use the exact budget including equality.
The JSON verdict has two prices. The flat calculation serves as a control, using the lower rates on the same counts. The tiered calculation alone selects the exit code and controls dispatch. ALLOW exits with 0, BLOCK with 1, and HOLD with 2. For a hold, the JSON can report the fields it validated before the failure. The two prices stay null when the inputs needed to compute them are missing or unsupported.
#!/usr/bin/env python3 import argparse import hashlib import json import re from pathlib import Path ROUTE = { "product": "gemini-enterprise-agent-platform", "publisher": "google", "apiVersion": "v1", "method": "generateContent", "model": "gemini-3.1-pro-preview", "location": "global", "billingMode": "standard-paygo", } INPUT_THRESHOLD = 200_000 MAX_OUTPUT_TOKENS = 65_536 LOW_RATES = (2, 12) # micro-USD per token, input then output HIGH_RATES = (4, 18) SOURCE = "synthetic_fixture" EXIT_CODE = {"ALLOW": 0, "BLOCK": 1, "HOLD": 2} def digest(raw): return hashlib.sha256(raw).hexdigest() def unique_object(pairs): result = {} for key, value in pairs: if key in result: raise ValueError("duplicate JSON field") result[key] = value return result def reject_constant(_value): raise ValueError("non-JSON numeric constant") def load_json(raw): return json.loads( raw.decode("utf-8"), object_pairs_hook=unique_object, parse_constant=reject_constant, ) def require(condition, reason): if not condition: raise ValueError(reason) def usd(micro_usd): dollars, micros = divmod(micro_usd, 1_000_000) return f"{dollars}.{micros:06d}" def parse_cap(value): require( re.fullmatch(r"[0-9]+(?:\.[0-9]{1,6})?", value), "cap must be nonnegative decimal USD with up to six fractional digits", ) dollars, _, fraction = value.partition(".") return int(dollars) * 1_000_000 + int(fraction.ljust(6, "0")) def validate_parts(parts): require(isinstance(parts, list) and parts, "expected nonempty text parts") for part in parts: require( isinstance(part, dict) and set(part) == {"text"} and isinstance(part["text"], str), "only plain text parts are supported", ) part["text"].encode("utf-8") def output_reserve(request): require(isinstance(request, dict) and set(request) == {"route", "body"}, "expected route and body") require(request["route"] == ROUTE, "unsupported route") body = request["body"] require(isinstance(body, dict) and {"contents", "generationConfig"} <= set(body) and set(body) <= {"contents", "generationConfig", "systemInstruction"}, "unsupported or missing request body field") contents = body["contents"] require(isinstance(contents, list) and contents, "expected nonempty contents") for turn in contents: require(isinstance(turn, dict) and set(turn) == {"role", "parts"} and turn["role"] in ("user", "model"), "unsupported text turn") validate_parts(turn["parts"]) if "systemInstruction" in body: instruction = body["systemInstruction"] require(isinstance(instruction, dict) and set(instruction) == {"parts"}, "unsupported system instruction shape") validate_parts(instruction["parts"]) config = body["generationConfig"] require(isinstance(config, dict) and set(config) == {"candidateCount", "maxOutputTokens"}, "expected explicit candidate count and output reserve") count = config["candidateCount"] reserve = config["maxOutputTokens"] require(type(count) is int and count == 1, "expected one candidate") require(type(reserve) is int and 1 <= reserve <= MAX_OUTPUT_TOKENS, "invalid output reserve") return reserve def read_bound(bound, request_sha256): require(isinstance(bound, dict) and set(bound) == {"source", "input_tokens_upper_bound", "request_sha256"}, "missing or unsupported bound fields") require(bound["source"] == SOURCE, "unconfirmed bound source") require(bound["request_sha256"] == request_sha256, "request SHA-256 mismatch") tokens = bound["input_tokens_upper_bound"] require(type(tokens) is int and tokens >= 0, "invalid input upper bound") return tokens def price_micro_usd(input_tokens, output_tokens, rates): input_rate, output_rate = rates return input_tokens * input_rate + output_tokens * output_rate def evaluate(raw, bound_raw, cap_text, on_allow, result): cap = parse_cap(cap_text) result["cap_usd"] = usd(cap) result["request_sha256"] = digest(raw) reserve = output_reserve(load_json(raw)) result["output_tokens_reserved"] = reserve upper = read_bound(load_json(bound_raw), result["request_sha256"]) lower_tier = upper <= INPUT_THRESHOLD rates = LOW_RATES if lower_tier else HIGH_RATES flat = price_micro_usd(upper, reserve, LOW_RATES) tiered = price_micro_usd(upper, reserve, rates) allowed = tiered <= cap result.update( verdict="ALLOW" if allowed else "BLOCK", reason="estimate within cap" if allowed else "estimate exceeds cap", tier="at_or_below_200k" if lower_tier else "above_200k", bound_source=SOURCE, input_tokens_upper_bound=upper, flat_estimate_usd=usd(flat), tiered_estimate_usd=usd(tiered), ) if allowed: on_allow(raw) class GateParser(argparse.ArgumentParser): def error(self, message): raise ValueError(f"invalid CLI arguments: {message}") def main(): parser = GateParser(description="Offline Gemini Standard PayGo budget demo") parser.add_argument("--request", type=Path, required=True) parser.add_argument("--bound", type=Path, required=True) parser.add_argument("--cap-usd", required=True) result = dict.fromkeys(( "tier", "input_tokens_upper_bound", "output_tokens_reserved", "cap_usd", "flat_estimate_usd", "tiered_estimate_usd", "bound_source", "request_sha256", )) result.update(verdict="HOLD", estimate_kind="synthetic estimate from published list rates") callbacks = [] def local_dispatch(verified_bytes): callbacks.append(digest(verified_bytes)) try: args = parser.parse_args() evaluate(args.request.read_bytes(), args.bound.read_bytes(), args.cap_usd, local_dispatch, result) except OSError: result.update(verdict="HOLD", reason="could not read input file") except (ValueError, RecursionError) as exc: result.update(verdict="HOLD", reason=str(exc)) result.update(callback_calls=len(callbacks), callback_request_sha256=next(iter(callbacks), None)) print(json.dumps(result, sort_keys=True)) return EXIT_CODE[result["verdict"]] if __name__ == "__main__": raise SystemExit(main()) Save the following as make_fixture.py beside the gate. It builds the three bound records against exactly the same request bytes, which keeps the spend decision isolated from changes in the JSON. The request contains a prior model turn, the latest build result as plain text, and a system instruction. The scripts need no API key.
import json from pathlib import Path from gemini_budget_gate import ROUTE, digest request = { "route": ROUTE, "body": { "contents": [ {"role": "user", "parts": [{"text": "Review a report parser change."}]}, {"role": "model", "parts": [{"text": "Send the diff and build result."}]}, {"role": "user", "parts": [{"text": "Diff: strip trailing space. Build: passed."}]}, ], "systemInstruction": {"parts": [{"text": "Review only the supplied diff."}]}, "generationConfig": {"candidateCount": 1, "maxOutputTokens": 1_000}, }, } raw = (json.dumps(request, indent=2) + "\n").encode("utf-8") Path("request.json").write_bytes(raw) for upper in (199_999, 200_000, 200_001): bound = { "source": "synthetic_fixture", "input_tokens_upper_bound": upper, "request_sha256": digest(raw), } Path(f"bound_{upper}.json").write_text( json.dumps(bound, indent=2) + "\n", encoding="utf-8" ) Run the fixture writer and price the first upper bound above the threshold. The final shell line reports the exit status of the gate.
python3 make_fixture.py python3 gemini_budget_gate.py --request request.json --bound bound_200001.json --cap-usd 0.60 printf 'exit=%s\n' "$?" {"bound_source": "synthetic_fixture", "callback_calls": 0, "callback_request_sha256": null, "cap_usd": "0.600000", "estimate_kind": "synthetic estimate from published list rates", "flat_estimate_usd": "0.412002", "input_tokens_upper_bound": 200001, "output_tokens_reserved": 1000, "reason": "estimate exceeds cap", "request_sha256": "8b71840ee9cbea3734308ca6fa4f05e3c4a482f034d8cbf3eec86c1a7896743d", "tier": "above_200k", "tiered_estimate_usd": "0.818004", "verdict": "BLOCK"} exit=1 Where does the flat estimate underquote the request?
For the fixture with an upper bound of 200,001 input tokens and a 1,000-token output reserve, the two modeled decisions differ at caps from $0.412002 inclusive to $0.818004 exclusive, in whole microdollars. Those endpoints follow from pricing the same counts under each set of rates. The flat column shows what the lower-rate calculation would decide. The last column records what the tier-aware gate actually did with its local callback.
| Cap in USD | Lower rates throughout | Tier-aware gate | Callback calls |
|---|---|---|---|
| 0.412001 | BLOCK | BLOCK | 0 |
| 0.412002 | ALLOW | BLOCK | 0 |
| 0.600000 | ALLOW | BLOCK | 0 |
| 0.818003 | ALLOW | BLOCK | 0 |
| 0.818004 | ALLOW | ALLOW | 1 |
| 0.818005 | ALLOW | ALLOW | 1 |
The $0.406004 jump between the 200,000 and 200,001 rows comes from the tiered estimates at the same output reserve. That's a different subtraction from comparing the two calculators on a single row. The former tells you the ...

