Skip to content

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 mode

Provider id: gemini. SDK adapter: OpenAI-compatibility mode on Google's generativelanguage API.

Env vars

VarDefaultNotes
ONGRID_GEMINI_API_KEYEmpty = provider dropped
ONGRID_GEMINI_MODELgemini-2.5-proDefault model
ONGRID_GEMINI_BASE_URLhttps://generativelanguage.googleapis.com/v1beta/openaiOpenAI-compat endpoint
ONGRID_GEMINI_MODELSgemini-3.5-flash,gemini-2.5-pro,gemini-2.5-flashCatalog 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:

  1. Google's native generativelanguage.googleapis.com/v1beta/generateContent shape, distinct from OpenAI's.
  2. An OpenAI-compatibility layer at .../v1beta/openai/ — accepts OpenAI-style chat/completions requests, 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=gemini

BaseURL

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_url content block; the BaseTool surface doesn't yet expose image params.

See also