Integration

Google Gemini through the Vigil proxy

The Gemini Developer API at generativelanguage.googleapis.com, with implicit caching on the provider’s side. Point your SDK's base URL at Vigil, add one header, and every Google Gemini call is logged with its cost, tokens, latency, errors and agent, then forwarded to https://generativelanguage.googleapis.com unchanged unless you switch on an optimisation. Prompt caching never changes answers. History trimming and model routing can: both are opt-in, run in Shadow first, and stop automatically if errors, cut-off answers or failed answers rise.

What Vigil records per Google Gemini call

Each Google Gemini call is one record: model id, tokens, cache reads and writes, latency, status, error code and agent. What a record holds, what happens to your Google Gemini key and what the hop costs in latency are answered once in the FAQ: what Vigil sees, your provider key and added latency.

Cost is computed from the proxy's rate registry, which prices 6 models on this platform today. A model the registry has no row for is logged with its cost left empty, never estimated.

  • gemini-3.1-pro-preview
  • gemini-3.5-flash
  • gemini-3.5-flash-lite
  • gemini-3.6-flash
  • gemini-3.7-flash
  • gemini-3.8-flash

Price per token, by model: Gemini 3.1 Pro, Gemini 3.8 Flash.

Setup

The Google Gemini base URL is https://api.vigil.tools/{user_id}/google; a request path such as /v1beta/models/{model}:generateContent is forwarded unchanged, and your Google Gemini key stays in GOOGLE_API_KEY. The two Vigil headers, the modes and the error codes are the same for every provider: see the LLM proxy setup.

your Gemini client
import { GoogleGenerativeAI } from "@google/generative-ai";

const genAI = new GoogleGenerativeAI(process.env.GOOGLE_API_KEY!, {
  httpOptions: { baseUrl: "https://api.vigil.tools/{user_id}/google" },
});

const model = genAI.getGenerativeModel(
  { model: "gemini-3.5-flash" },
  {
    customHeaders: new Headers({
      "X-Vigil-Key": "vk_your_vigil_key",
      "X-Vigil-Agent": "my-agent",
    }),
  },
);

const result = await model.generateContent("Hello!");

The header name and value are certain; this SDK’s plumbing for setting them is not — it has not been smoke-tested against a live call. If it does not work, the curl format is the ground truth for exactly what Vigil expects.

Python: No verified Python example for Gemini yet — the SDK’s per-request header hook has not been verified here. Use the curl format: it is the exact request Vigil expects, and any client that lets you set a base URL and a header will work.

terminal
curl https://api.vigil.tools/{user_id}/google/v1beta/models/gemini-3.5-flash:generateContent \
  -H "content-type: application/json" \
  -H "x-goog-api-key: $GOOGLE_API_KEY" \
  -H "X-Vigil-Key: vk_your_vigil_key" \
  -H "X-Vigil-Agent: my-agent" \
  -d '{
    "contents": [{ "parts": [{ "text": "Hello!" }] }]
  }'

The request shape here follows the provider’s published REST API but has not been smoke-tested through Vigil. The URL and the two Vigil headers are certain.

Prompt caching on Google Gemini

This provider caches automatically, on its own terms. Vigil records what it reports and prices it — there is nothing for Vigil to add to the request.

With optimisation On: the provider caches automatically or not at all; Vigil records cache use and does not change the request. In Shadow, Vigil measures what caching would have saved and changes nothing. Off records the call and nothing more.

Questions

Which Google Gemini models does Vigil price?
6 models with a published rate in the registry: gemini-3.1-pro-preview, gemini-3.5-flash, gemini-3.5-flash-lite, gemini-3.6-flash, gemini-3.7-flash, gemini-3.8-flash. A call to any other Google Gemini model is logged and monitored, with its cost left empty rather than guessed.

Other providers: Anthropic · AWS Bedrock · Google Vertex · OpenAI · Mistral · xAI Grok · DeepSeek · Together AI · Fireworks AI · Groq · Cerebras · Baseten · Moonshot · Z.ai · Cloudflare Workers AI · OpenRouter