Piggyback on Gemini CLI auth for an OpenAI-compatible API
A Cloudflare Worker that exposes Google’s Gemini models through OpenAI-shaped endpoints by recycling the official CLI’s OAuth2 tokens.

What it does
This Cloudflare Worker sits between your OpenAI-speaking clients and Google’s Gemini API, translating requests and responses on the fly. It uses OAuth2 credentials lifted from the official Gemini CLI’s local config, so you don’t need a separate Google Cloud API key. Any client that expects an OpenAI /v1/chat/completions endpoint—Cline, Open WebUI, LiteLLM, or the standard SDK—can point at this worker and talk to Gemini 2.5 Pro or Flash instead.
The interesting bit
The project’s central trick is borrowing the Gemini CLI’s existing Google login rather than building its own auth flow; you copy the tokens from ~/.gemini/oauth_creds.json and the worker handles refresh cycles via Cloudflare KV. It also maps Gemini’s native reasoning capabilities onto OpenAI’s API surface, offering both real thinking budgets and a ENABLE_FAKE_THINKING mode that synthesizes reasoning text when you just want to test the plumbing.
Key highlights
- Drop-in
/v1/chat/completionswith streaming, vision, tool calling, and model enumeration - Supports Gemini 2.5 Pro/Flash with configurable
thinking_budgetandreasoning_effortcontrols - Automatic fallback from Pro to Flash when rate limits hit
- KV-backed token caching to avoid hammering Google’s OAuth2 refresh endpoint
- Taps into the Gemini CLI auth path, including access to Google’s Code Assist free tier
Caveats
- You must extract OAuth2 credentials from the official Gemini CLI’s local config; there is no standalone login flow.
- Token refresh can fail if the credentials come from the wrong OAuth2 client or the refresh token is revoked.
- Project ID auto-discovery sometimes fails, requiring a manual override.
Verdict Deploy this if you want to pipe Gemini 2.5 through your existing OpenAI toolchain without setting up Google Cloud billing. Look elsewhere if you need a fully independent, first-party API key.
Frequently asked
- What is GewoonJaap/gemini-cli-openai?
- A Cloudflare Worker that exposes Google’s Gemini models through OpenAI-shaped endpoints by recycling the official CLI’s OAuth2 tokens.
- Is gemini-cli-openai open source?
- Yes — GewoonJaap/gemini-cli-openai is an open-source project tracked on heatdrop.
- What language is gemini-cli-openai written in?
- GewoonJaap/gemini-cli-openai is primarily written in TypeScript.
- How popular is gemini-cli-openai?
- GewoonJaap/gemini-cli-openai has 892 stars on GitHub.
- Where can I find gemini-cli-openai?
- GewoonJaap/gemini-cli-openai is on GitHub at https://github.com/GewoonJaap/gemini-cli-openai.