feat: add native Gemini support to openai_compat provider#3049
Open
Ajinkya-Kardile wants to merge 3 commits into
Open
feat: add native Gemini support to openai_compat provider#3049Ajinkya-Kardile wants to merge 3 commits into
Ajinkya-Kardile wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR enables native integration with Google Gemini by updating the
wire_model_for_base_urllogic in theopenai_compatprovider.Previously, when using a custom
OPENAI_BASE_URL(such as the Google Generative Language API endpoint),claw-codewould preserve theopenai/prefix in the outgoing JSON payload. This caused API requests to fail because the Google API does not recognize model identifiers like:This change adds
geminito the stripping logic, ensuring that model slugs are correctly normalized to the format expected by the Google Gemini API while maintaining compatibility for other OpenAI-compatible gateways.Commands Run
To verify this change, the following commands were executed inside the
rust/workspace:✅ Passed
✅ Passed
cargo test --workspace✅ Passed
Manual Verification
Environment
Command Executed
./target/release/claw --model openai/gemini-2.5-flash prompt "reply with ready"Result
✅ Successfully received a response from Gemini.
Compatibility Risks
CLI / Provider Behavior
This changes how
openai/model slugs are sanitized when a non-defaultOPENAI_BASE_URLis detected.The logic specifically targets models containing
"gemini"to avoid prefix corruption while preserving compatibility with existing OpenAI-compatible providers.Windows / PowerShell
No changes were made to build scripts, shell integrations, or documentation.
The modification is isolated entirely within the Rust
apicrate.Known Gaps
None.
This implementation follows the existing normalization pattern already used for providers such as:
xaiqwenkimiand adheres to the current crate boundaries and provider architecture.