Google Gemini

Both Google SDKs are recorded on the synchronous path. Async and streaming are not. Includes the rolling-alias billing behaviour.

Google ships two Python SDKs and the Capsera SDK patches both.

PackageImportStatus
google-genaifrom google import genaiCurrent
google-generativeaiimport google.generativeai as genaiDeprecated by Google

Coverage

CallRecorded
client.models.generate_content(...) (google-genai)Yes
model.generate_content(...) (google-generativeai)Yes
await model.generate_content_async(...) (google-generativeai)Yes
async on google-genai (client.aio...)No
streaming, either SDKNo
embed_contentNo
provider errors on recorded pathsYes

Synchronous only, apart from the deprecated SDK's generate_content_async. Calls through client.aio.models.generate_content(...) or any streaming variant are not recorded. Use record() for those.

Current SDK

from google import genai
import capsera

capsera.init(api_key=os.environ["CAPSERA_API_KEY"])
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])

response = client.models.generate_content(
    model="gemini-2.5-flash",
    contents="Summarise this incident report.",
)

Deprecated SDK

Recorded, including its async method:

import google.generativeai as genai

genai.configure(api_key=os.environ["GOOGLE_API_KEY"])
model = genai.GenerativeModel("gemini-2.5-flash")

response = model.generate_content("Summarise this incident report.")
response = await model.generate_content_async("And again, asynchronously.")

Google has ended support for this package. Capsera records either one.

Rolling aliases

Gemini accepts aliases that resolve to a concrete model, such as gemini-flash-latest, gemini-flash-lite-latest, and gemini-pro-latest. An alias cannot be priced, because what it points to changes without notice.

The SDK records the model reported in the response rather than the one requested. If you request gemini-flash-lite-latest, the event records the concrete version that served it, such as gemini-3.5-flash-lite.

Without this behaviour, alias requests match nothing in the pricing catalog and fall back to a generic estimate. It also means the model name in your dashboard can differ from the string in your code.

Free-tier model availability

Google retires free-tier access to older models fairly quickly. gemini-2.0 returned limit: 0 for new keys while still being documented.

A 404 ... no longer available to new users response means the model is unavailable for your key rather than that your code is wrong.

If cost appears where there was none before, you were moved to a paid model. The recorded model name identifies which one.

Models

The catalog covers Gemini from 1.5 through the current generation, including the 2.5 and 3.x families, priced at Developer API rates for prompts up to 200k tokens.

Vertex AI prices differ from the Developer API for the same model, so the catalog keys them separately. gemini-2.0-flash-001 is the Vertex entry and gemini-2.0-flash the Developer API one. See Mistral, Cohere and Vertex AI for Vertex.