Docs / Recipes / Gemini SDK

// LANGUAGE SDK · GEMINI

Gemini SDK (native generateContent)

Pattern A · full governance

Keep the official google-genai SDK. Point it at the Agentics native ingress and pass your ak_ key as the Google API key — it is sent as x-goog-api-key: ak_… and every call is governed and receipted.

Pattern A — routed through the gateway. Your call travels through Agentics via a base-URL swap, so it is governed (routing, budgets, guardrails) inline and the Proof Ledger writes one verifiable receipt server-side. The receipt hash comes back in the x-agentics-receipt response header.

Install

shell
pip install google-genai

Point the SDK at Agentics

Set the client's base_url to https://agentics.you. Your ak_ key is sent as x-goog-api-key.

Python
from google import genai client = genai.Client( api_key="ak_…", # sent as x-goog-api-key: ak_… http_options={"base_url": "https://agentics.you"}, ) resp = client.models.generate_content( model="gemini-2.5-pro", contents="hi", ) print(resp.text)

Run one call → see the receipt

To read the receipt header directly, call the native endpoint over raw HTTP:

cURL
curl "https://agentics.you/v1beta/models/gemini-2.5-pro:generateContent" -i \ -H "x-goog-api-key: ak_…" \ -H "content-type: application/json" \ -d '{"contents":[{"parts":[{"text":"hi"}]}]}' # response header: x-agentics-receipt: <receipt_hash>

Or tail the ledger after any SDK call: agentics log tail --limit 1 prints the x-agentics-receipt for your last call.