Gemini provider guide
Route requests to Google's Gemini models through Otari, using a Gemini API key from Google AI Studio. For Gemini on Google Cloud, use the vertex provider instead. See any-llm's supported providers for the current provider list and Models for Otari's model-name format.
What you'll set up
A Gemini provider entry in your config.yml that reads your key from GEMINI_API_KEY (or the key stored on the dashboard's Providers page), then a first request that Otari routes to Gemini.
Prerequisites
Otari running locally (see the Quickstart)
A Gemini API key from https://aistudio.google.com/apikey
Configure
Add Gemini under providers: in your config.yml:
providers:
gemini:
api_key: "AIza..." # your Gemini API keyTo keep your provider key out of the file with environment interpolation:
providers:
gemini:
api_key: ${GEMINI_API_KEY}...then export it before starting Otari:
GEMINI_API_KEYalone is not enough, and neither is a baregemini:entry: Otari reads the variable only where an entry names it, as theapi_key: ${GEMINI_API_KEY}line above does. The dashboard's Providers page and an organization's own key work too.
Choose a model
Models are addressed as gemini:<model>:
Everything after the colon is passed straight to Gemini, so any model your key can access works. Google retires older models for new keys, so check the model list if a name is rejected.
Chat completions take only text-generation models. Embedding models such as gemini-embedding-001 do not work there; send them to POST /api/v1/embeddings instead (see the API reference).
Verify
If you have not already started Otari and created a client key, follow the Quickstart first.
Then make a request with the Otari Python SDK (pip install otari; any OpenAI-compatible client also works), using a gemini:<model> selector:
Expected (sample) output:
Troubleshooting
HTTP 400 API key not valid. Please pass a valid API key.
Gemini rejected the api_key Otari sent. Check the api_key (or GEMINI_API_KEY) configured on the gateway.
HTTP 404 This model ... is no longer available to new users
Google has retired that model for new keys. Use the model the message suggests.
HTTP 429 You exceeded your current quota (code upstream_rate_limited)
Your key's quota for that model is used up or is zero, which is common for Pro models on the free tier. Wait, pick another model, or enable billing in Google AI Studio.
HTTP 502 The provider failed the request with HTTP 503
Gemini is overloaded or failed on its side. These are retryable.
HTTP 402 No pricing configured for model ...
Otari could not resolve pricing for that model and require_pricing rejected the request. Add a pricing: entry, enable default_pricing: true for bundled fallback pricing, or use a model that already has pricing coverage.
Last updated
Was this helpful?
