diff --git a/src/providers/gemini.rs b/src/providers/gemini.rs index 393963cf..98f12b39 100644 --- a/src/providers/gemini.rs +++ b/src/providers/gemini.rs @@ -563,13 +563,16 @@ impl GeminiProvider { /// Determine the appropriate base URL for the model. /// "preview" models often require the v1beta endpoint, but newer promoted ones may be on v1. fn get_base_url(&self, model: &str) -> String { - // Gemini 3 and other reasoning/preview models often perform better or - // strictly require v1beta for advanced features like thought_signatures. - if model.contains("preview") || model.contains("thinking") || model.contains("gemini-3") { - self.config.base_url.replace("/v1", "/v1beta") - } else { - self.config.base_url.clone() + let base = &self.config.base_url; + + // If the model requires v1beta but the base is currently v1 + if (model.contains("preview") || model.contains("thinking") || model.contains("gemini-3")) && base.ends_with("/v1") { + return base.replace("/v1", "/v1beta"); } + + // If the model is a standard model but the base is v1beta, we could downgrade it, + // but typically v1beta is a superset, so we just return the base as configured. + base.clone() } /// Default safety settings to avoid blocking responses.