From 679396bfa27d6c66a37dc131d0d8cbfa779b0f9b Mon Sep 17 00:00:00 2001 From: ajinkya Date: Tue, 19 May 2026 12:44:55 +0530 Subject: [PATCH 1/2] added: Add native Gemini support by stripping prefix in wire_model_for_base_url --- rust/crates/api/src/providers/openai_compat.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/rust/crates/api/src/providers/openai_compat.rs b/rust/crates/api/src/providers/openai_compat.rs index 1d53f120b4..53a66cc979 100644 --- a/rust/crates/api/src/providers/openai_compat.rs +++ b/rust/crates/api/src/providers/openai_compat.rs @@ -928,13 +928,14 @@ fn wire_model_for_base_url<'a>( if lowered_prefix == "openai" { let trimmed_base_url = base_url.trim_end_matches('/'); let default_openai = DEFAULT_OPENAI_BASE_URL.trim_end_matches('/'); + if matches!(lowered_prefix.as_str(), "xai" | "grok" | "kimi" | "gemini") { + return Cow::Borrowed(&model[pos + 1..]); + } if config.provider_name == "OpenAI" && trimmed_base_url != default_openai { - // OpenAI-compatible gateways such as OpenRouter commonly use - // slash-containing model slugs (for example `openai/gpt-4.1-mini`). - // Preserve the slug when the user configured a non-default OpenAI - // base URL; the prefix still routed to the OpenAI-compatible client, - // but the gateway owns the final model namespace. - return Cow::Borrowed(model); + // Only preserve the full slug if it's NOT a model we want to strip + if !model.contains("gemini") { + return Cow::Borrowed(model); + } } return Cow::Borrowed(&model[pos + 1..]); } From be36d5ef413a4c2f4d192cc8573d971cc51de8b9 Mon Sep 17 00:00:00 2001 From: ajinkya Date: Tue, 19 May 2026 15:42:26 +0530 Subject: [PATCH 2/2] added: Add native Gemini support by stripping prefix in wire_model_for_base_url --- rust/crates/api/src/providers/openai_compat.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rust/crates/api/src/providers/openai_compat.rs b/rust/crates/api/src/providers/openai_compat.rs index 53a66cc979..4f199a3e94 100644 --- a/rust/crates/api/src/providers/openai_compat.rs +++ b/rust/crates/api/src/providers/openai_compat.rs @@ -928,12 +928,12 @@ fn wire_model_for_base_url<'a>( if lowered_prefix == "openai" { let trimmed_base_url = base_url.trim_end_matches('/'); let default_openai = DEFAULT_OPENAI_BASE_URL.trim_end_matches('/'); - if matches!(lowered_prefix.as_str(), "xai" | "grok" | "kimi" | "gemini") { + if matches!(lowered_prefix.as_str(), "xai" | "grok" | "kimi" | "gemini" | "gemma") { return Cow::Borrowed(&model[pos + 1..]); } if config.provider_name == "OpenAI" && trimmed_base_url != default_openai { // Only preserve the full slug if it's NOT a model we want to strip - if !model.contains("gemini") { + if !model.contains("gemini") && !model.contains("gemma") { return Cow::Borrowed(model); } }