Expose Gemini CLI as OpenAI API via Cloudflare Workers
Top 70.7% on sourcepulse
This project provides a Cloudflare Worker that exposes Google's Gemini models via an OpenAI-compatible API. It's designed for developers and users who want to leverage Gemini's advanced AI capabilities through familiar OpenAI SDKs and tools, offering a seamless integration experience without requiring direct API keys.
How It Works
The worker acts as a proxy, translating OpenAI API requests into the format expected by Google's Code Assist API. It utilizes OAuth2 authentication, managed via Cloudflare Workers KV storage for token caching and refresh, eliminating the need for users to handle API keys directly. This approach allows for low-latency, globally distributed access to Gemini models, supporting features like streaming, tool calling, and multimodal input.
Quick Start & Requirements
npm install -g @cloudflare/wrangler
gemini-cli
, create a KV namespace, configure .dev.vars
with credentials, and deploy using wrangler deploy
.Highlighted Details
Maintenance & Community
The project is maintained by GewoonJaap. Contributions are welcome via pull requests.
Licensing & Compatibility
Licensed under the MIT License. Compatible with commercial and closed-source applications.
Limitations & Caveats
Relies on Google's Code Assist API, which may have usage limits and terms of service. Users must ensure compliance with Google's policies. The "thinking" feature might require specific configuration for optimal results.
3 days ago
Inactive