Skip to main content

Google Gemini LLM

GoogleLLM plugs Google Gemini chat models into Patter’s pipeline mode via the google-genai SDK. It supports both the Gemini Developer API (with an API key) and Vertex AI (with GCP project + location). Streams normalise to Patter’s unified {type: "text" | "tool_call" | "done"} chunk protocol, and Gemini function_call parts map directly onto Patter tools.
This page covers Google Gemini in chat-completions mode for the pipeline (STT → LLM → TTS). For Gemini’s bidirectional speech-to-speech engine, see the separate gemini-live adapter under Engines.

Install

Usage

The namespaced import (from getpatter.llm import google / import * as google from "getpatter/llm/google") auto-resolves the API key from GEMINI_API_KEY first, then GOOGLE_API_KEY for parity with other SDKs, and exposes a uniform LLM class.
Plug it into an agent:

Supported models

Pricing in USD per 1M tokens. gemini-2.0-flash, gemini-2.0-flash-lite, gemini-1.5-flash, and gemini-1.5-pro are shut down and no longer supported. For the speech-to-speech variants — gemini-3.1-flash-live-preview (text in 0.75/out0.75 / out 4.50, audio in 3.00/1Mtokens=3.00/1M tokens = 0.005/min / out 12.00/1Mtokens=12.00/1M tokens = 0.018/min) and gemini-2.5-flash-native-audio-preview (text in 0.50/out0.50 / out 2.00, audio in 3.00/out3.00 / out 12.00) — see the Engines page; they are separate Realtime adapters, not chat-completions models.

Environment variables

Options

Vertex AI

Switch to Vertex AI when you need GCP-native auth (service accounts), VPC Service Controls, regional residency, or per-project billing isolation.
The google-genai SDK picks up Application Default Credentials automatically — set GOOGLE_APPLICATION_CREDENTIALS to a service-account key path or run gcloud auth application-default login for local dev.

Function calling

Gemini’s function_call parts map directly onto Patter tools — define a tool once and it works on every LLM provider. Patter assigns a monotonically increasing index per function_call part since Gemini does not provide a stable per-call index across stream chunks. Token usage is collected from usage_metadata (cumulative on each chunk; only the last value is yielded as a usage event to avoid double-counting).