Gemini
TL;DR
bash
ONGRID_GEMINI_API_KEY=...
ONGRID_GEMINI_MODEL=gemini-2.5-pro # default
ONGRID_GEMINI_BASE_URL= # defaults to generativelanguage.googleapis.com OAI modeProvider id: gemini. SDK adapter: OpenAI-compatibility mode on Google's generativelanguage API.
Env vars
| Var | Default | Notes |
|---|---|---|
ONGRID_GEMINI_API_KEY | — | Empty = provider dropped |
ONGRID_GEMINI_MODEL | gemini-2.5-pro | Default model |
ONGRID_GEMINI_BASE_URL | https://generativelanguage.googleapis.com/v1beta/openai | OpenAI-compat endpoint |
ONGRID_GEMINI_MODELS | gemini-3.5-flash,gemini-2.5-pro,gemini-2.5-flash | Catalog list |
Default catalog
gemini-3.5-flash— frontier; fast and surprisingly cheap.gemini-2.5-pro— the catalog default; balanced.gemini-2.5-flash— the cheap one.
Why the OAI-compat endpoint
Gemini has two API surfaces:
- Google's native
generativelanguage.googleapis.com/v1beta/—generateContentshape, distinct from OpenAI's. - An OpenAI-compatibility layer at
.../v1beta/openai/— accepts OpenAI-stylechat/completionsrequests, returns OpenAI-shaped responses.
Ongrid uses #2. The compatibility layer means the eino-openai adapter works unchanged, and tool calls / system messages / streaming all behave like every other provider's slot. No special handling.
If you need a Gemini-only feature that the OAI-compat surface doesn't expose (e.g. media inputs the OAI shape can't represent), drop in a custom adapter — that's outside the supported configuration.
Making Gemini the default
bash
ONGRID_LLM_DEFAULT_PROVIDER=geminiBaseURL
The default routes through generativelanguage.googleapis.com. Use the BaseURL override for:
- Vertex AI proxy endpoints (typically
us-central1-aiplatform...). - Corporate Google Cloud relays.
The hint shown in the Settings UI for this field is "Google generativelanguage.googleapis.com (OpenAI compatibility mode)".
Quirks
- Region restrictions — some Gemini models are not available in every region. A 403 from the upstream lands in the chat transcript as a regular API error; check the provider's region matrix if you get this.
- Safety filters — Google's content filters can return an empty message with a
finishReason: SAFETY. The Ongrid adapter renders this as an explicit "blocked by safety filter" message in the chat rather than an empty answer. - Vision — image inputs work over the OAI-compat layer using the standard
image_urlcontent block; the BaseTool surface doesn't yet expose image params.