Skip to main content

Installation

Usage

How It Works

wrap_gemini wraps the Google Gen AI client’s generate_content method. After each call, it:
  1. Extracts the model name from the response usage_metadata
  2. Extracts input and output token counts from usage_metadata
  3. Sends the usage event to MeshAI (buffered, non-blocking)
Works with both the new unified google-genai SDK and the legacy google-generativeai SDK.

Alternative: Proxy (Zero-Code)

There is no dedicated Gemini proxy route. Gemini traffic can be routed through the proxy’s Vertex AI provider instead, using the Vertex path format, which requires the location and project in the URL:
For example:
This requires a Vertex AI project and Google Cloud credentials (a bearer token from ADC or a service account), not a plain Gemini API key.