Skip to content

Gemini model behaviour

The Gemini API's own vocabulary — finishReason, safety settings, function-calling modes, stopSequences — and what each one does to a response you were expecting.

The Gemini API was not designed as a variant of anybody else’s. It has its own request body, its own names for things that exist elsewhere under different names, and a few concepts—grounding metadata, thinking budgets, explicit context caches—that have no equivalent in the chat-completions shape most people learned first. Nearly every surprise it produces is a consequence of that vocabulary rather than of the model: an empty answer is usually a finishReason you did not read, a dropped instruction is usually a system_instruction that was posted inside contents, and a truncated JSON object is usually an output ceiling doing exactly what it is documented to do.

These pages take the API on its own terms. Each one starts from the field as Google documents it—the literal key, the literal enum values, the literal place in the body—and works out to the behaviour you can observe. Where a figure is per-model or has changed between generations, it is named as such and pointed at the live reference rather than frozen into prose, because Gemini’s numbers move more than most.

Gemini 1.5 Pro's Context Window and the Long-Context Caveat

The 2,097,152-token input ceiling, what that many tokens actually holds, and Google's own documented limit on how well retrieval holds up at the top of the range.

9 min read

system_instruction in the Gemini API: A Separate Field From contents

Why Gemini takes the system prompt as a top-level sibling of contents rather than as a message, and what breaks when you post it as one.

8 min read

Function Calling Modes in the Gemini API: AUTO, ANY and NONE

What tool_config.function_calling_config does to the same prompt under each mode, and why ANY is the one that changes the response type.

9 min read

Gemini's Safety Settings: The Harm Categories and Threshold Levels

The adjustable harm categories, the block thresholds each accepts, and the two places in a response where a safety decision shows up.

9 min read

generateContent and streamGenerateContent: Gemini's Two Response Modes

The streamed chunk shape set against the single-response shape, including the alt=sse flag that decides whether you get server-sent events or a streamed JSON array.

9 min read

Context Caching in the Gemini API: The Minimum Token Floor and TTL

Why an explicit cache has a minimum size at all, what the TTL is charging you for, and the request that fails because it is too small to cache.

9 min read

Grounding With Google Search in the Gemini API

The one-line tool declaration that turns on Search grounding, and the groundingMetadata structure that comes back when it fires.

9 min read

Gemini's Thinking Budget Parameter

Where thinkingBudget sits in the request, what its special values mean, and why the budget and your answer are competing for the same output allowance.

9 min read

Video Input in the Gemini API: How Frames Become Tokens

The frame-sampling rate, the per-second token rates Google documents, and the arithmetic for a clip of a given length — plus the one call that gives you the real number.

9 min read

Native Audio Input in the Gemini API

The accepted audio MIME types, the per-second token cost, and what a model that hears the audio can answer that a transcript cannot.

8 min read

JSON Output in the Gemini API: response_mime_type and response_schema

The two generationConfig fields that constrain output to a shape, the OpenAPI subset the schema is written in, and the Gemini-specific propertyOrdering field.

9 min read

Gemini's Max Output Tokens per Model

The documented output ceiling for the current Gemini models, why it is unrelated to the context window, and what thinking tokens take out of it.

8 min read

finishReason Values in the Gemini API and What Each One Means

Every documented finishReason against the condition that produces it, and why blockReason is a different field answering a different question.

9 min read

Gemini Model Version Suffixes: -latest, -001 and Stable Names

How to read a Gemini model string, which forms are aliases that move underneath you, and how to tell what actually served your request.

8 min read

Gemini's Model Deprecation and Retirement Schedule

How Google's model lifecycle works — legacy, deprecated, retired — where the dates are published, and what has already been retired.

8 min read

Gemini's Tokenizer: Why Token Counts Differ From GPT's

Why the same string is a different number of tokens on Gemini than on a GPT model, and how to get both numbers for text you care about.

8 min read

The countTokens Method in the Gemini API

How to call countTokens before a generation request, what comes back, and how to turn the number into a cost estimate you can act on.

9 min read

The candidateCount Parameter in the Gemini API

What asking Gemini for several candidates in one call returns, and what it does to the tokens you are billed for.

7 min read

Gemini Flash's Context Window and Output Cap

The documented input and output token limits for the Gemini Flash line, and why the two numbers are set independently.

7 min read

Gemini's Code Execution Tool: How It Runs and Returns Results Inline

How the built-in code execution tool is declared, what the executableCode and codeExecutionResult parts contain, and what the sandbox can and cannot do.

9 min read

Parallel Function Calling in the Gemini API

How one Gemini turn can carry several functionCall parts at once, and the one rule for answering them that most implementations get wrong.

8 min read

Why Gemini Returns an Empty Response With a Safety Block Reason

What to do when Gemini returns no candidates or an empty text field, and how to tell a prompt block from an output block.

9 min read

stopSequences in the Gemini API and Its Limits

How stopSequences truncates Gemini output, how many you may pass, and why the stop text does not appear in the result.

7 min read

Gemini's Knowledge Cutoff by Model

Where Google documents each Gemini model's training cutoff, what the date does and does not mean, and how to check it for the model you call.

8 min read

The Gemini File API: Uploading Large Files Instead of Inlining Them

How to upload a file to the Gemini File API and reference it by URI in a generation request, and the request size that forces you to.

9 min read

Implicit and Explicit Caching in the Gemini API

The difference between the automatic cache you get for free and the cachedContent resource you create and pay to keep.

8 min read

Enum-Constrained Output in the Gemini API

How to make Gemini choose from a fixed list of values instead of writing a sentence, using an enum schema and the right response MIME type.

7 min read

Sending Function Responses Back in a Multi-Turn Gemini Conversation

The full three-turn shape of a Gemini tool exchange, with the exact roles and parts for the functionCall and functionResponse pair.

9 min read

Gemini's Temperature Range: Why It Goes Above 1.0

The documented 0-to-2 temperature range on the Gemini API, what values above 1.0 actually do, and why providers document different ranges.

7 min read

The Gemini Live API: Streaming Session Shape for Real-Time Audio and Video

How a Live API WebSocket session is set up and what messages flow in each direction, and how it differs from streaming generateContent.

10 min read

Other topics