Gemini Integration
Oracle supports Gemini in two distinct ways:
- Gemini API mode (
--engine api) viaGEMINI_API_KEY - Gemini web (cookie) mode (
--engine browser) via your signed-in Chrome cookies atgemini.google.com(no API key required)
#Usage (API)
- Get an API Key: Obtain a key from Google AI Studio.
- Set Environment Variable: Export the key as
GEMINI_API_KEY. - Run Oracle: Use the
--model(or-m) flag to select Gemini.
``bash export GEMINI_API_KEY="your-google-api-key" ``
``bash oracle --engine api --model gemini --prompt "Explain quantum entanglement" ` You can also use the explicit model ID: `bash oracle --engine api --model gemini-3-pro --prompt "..." ` Or the 3.1 alias, which Oracle dispatches to Google's preview model id: `bash oracle --engine api --model gemini-3.1-pro --prompt "..." ``
#Usage (Gemini web / cookies)
Gemini web mode is a cookie-based client for gemini.google.com. It does not use GEMINI_API_KEY and does not drive ChatGPT.
Prereqs:
- Chrome installed.
- Signed into
gemini.google.comin the Chrome profile Oracle uses (default:Defaultprofile).
Examples:
# Text run
oracle --engine browser --model gemini-3-pro --prompt "Say OK."
# Deep Think browser run (manual-login profile recommended on macOS)
oracle --engine browser --browser-manual-login \
--model gemini-3-deep-think \
--prompt "Think carefully, then answer in one paragraph."
# Generate an image (writes an output file)
oracle --engine browser --model gemini-3-pro \
--prompt "a cute robot holding a banana" \
--generate-image out.jpg --aspect 1:1
# Edit an image (input via --edit-image, output via --output)
oracle --engine browser --model gemini-3-pro \
--prompt "add sunglasses" \
--edit-image in.png --output out.jpg
Notes:
- If your logged-in Gemini account can’t access “Pro”, Oracle will auto-fallback to a supported model for web runs (and logs the fallback in verbose mode).
- This path runs fully in Node/TypeScript (no Python/venv dependency).
--browser-model-strategyonly affects ChatGPT automation; Gemini web always uses the explicit Gemini model ID.gemini-3-deep-thinkis browser-only for now.--engine apirejects it instead of silently falling back to regular Gemini Pro.- If Chrome cookie extraction fails, the missing-cookie error now includes any cookie-reader warnings plus
--browser-manual-login/--browser-inline-cookies-fileguidance.
#Implementation details
#Gemini API adapter
src/oracle/gemini.ts— adapter using@google/genaithat returns aClientLike.- Model IDs:
gemini-3-promaps togemini-3-pro-preview;gemini-3.1-promaps togemini-3.1-pro-preview. - Request mapping:
OracleRequestBody→ Gemini request;web_search_previewmaps to Gemini search tooling. - Response mapping: Gemini responses →
OracleResponse. - Streaming: wraps Gemini’s async iterator as
ResponseStreamLike. src/oracle/run.ts— selectsGEMINI_API_KEYvsOPENAI_API_KEYbased on model prefix.src/oracle/config.ts/src/oracle/types.ts— model config +ModelName.
#Gemini web client (cookie-based)
src/gemini-web/client.ts— talks togemini.google.comand downloads generated images via authenticatedgg-dlredirects.src/gemini-web/executor.ts— browser-engine executor for Gemini (loads Chrome cookies and runs the web client).
#Testing
- Unit/regression:
pnpm vitest run tests/gemini.test.ts tests/gemini-web - Live (API):
ORACLE_LIVE_TEST=1 pnpm vitest run tests/live/gemini-live.test.ts - Live (Gemini web/cookies):
ORACLE_LIVE_TEST=1 pnpm vitest run tests/live/gemini-web-live.test.ts