Repository navigation
Description
Problem
Gemini CLI currently only works with Google's Gemini API. Users who want to use the excellent tooling, agent loop, and MCP integration with other models (OpenAI GPT, Anthropic Claude, local models via Ollama/vLLM) cannot do so.
This is the most requested capability for extending gemini-cli's reach. Projects like Qwen Code (a fork) have already proven demand by shipping multi-provider support.
Proposed Solution
Add an OpenAIContentGenerator that implements the existing ContentGenerator interface, translating between Gemini's native Content/Part format and OpenAI's Chat Completions API.
Activation: Set two environment variables:
export OPENAI_COMPATIBLE_ENDPOINT="https://api.openai.com"
export OPENAI_COMPATIBLE_API_KEY="sk-..."
export OPENAI_COMPATIBLE_MODEL="gpt-4o" # optionalWhat it enables:
- OpenAI (GPT-4o, o1, o3, GPT-5)
- Anthropic Claude (via OpenAI-compatible proxies like LiteLLM)
- Local models (Ollama, vLLM, llama.cpp)
- Corporate LLM gateways
- Any OpenAI-compatible API
Architecture (zero disruption to existing Gemini flow):
- New
OpenAIContentGeneratorclass implementingContentGenerator - Factory detection in
createContentGenerator()— env vars present → OpenAI path, otherwise → existing Gemini path unchanged - Full streaming via SSE parsing with tool call accumulation
- Model-aware
max_tokensdefaults to prevent output truncation - Pre-send context budget enforcement for smaller context windows
- Token limits expanded for Claude (200K), GPT-4o (128K), o1/o3 (200K)
What stays unchanged:
- All Gemini-native functionality
- Auth flows (OAuth, API key, Vertex AI, ADC)
- The agent loop, MCP integration, tools — all work identically
I have a PR ready with full test coverage (17 tests).
Activity
gemini-cli commentedon Mar 21, 2026
Found possible duplicate issues:
If you believe this is not a duplicate, please remove the
status/possible-duplicatelabel.gemini-cli commentedon May 9, 2026
A highly requested feature to allow the CLI to use OpenAI-compatible API endpoints.
Effort Analysis:
Adding support for an OpenAI-compatible endpoint involves implementing the
ContentGeneratorinterface and handling streaming via SSE parsing. This requires resolving asynchronous flows and tool execution integration within the core architecture, mapping to effort/medium.Adib234 commentedon May 9, 2026
Thank you for bringing this to our attention. Right now, our engineering team is focusing all resources on critical system maintenance and core stability. Because of this, we don't have immediate plans to address this specific issue, but we truly appreciate you flagging it for us.
WuJunkai2004 commentedon May 31, 2026
I write a https://github.com/WuJunkai2004/api-for-gemini for routing gemini cli's request to custom model provider, it may help you.
jaroslawjanas commentedon Jun 11, 2026
Yeah you have been saying this for almost a year now. I checked the issues.
Clearly this is just corporate speak for no.
You don't even have the guts to say it outright and I find it borderline offensive.
Don't Be Evil
smallcaseclassicking commentedon Aug 24, 2026
I checked past issues and saw they were just repeating the same phrase, so I created my own fork.