fix(gemini): resolve 404 by fixing double-beta in API URL
Some checks failed
CI / Check (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Formatting (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Release Build (push) Has been cancelled

- Update get_base_url to only perform replacement if the base_url specifically ends with /v1.
- This prevents malformed URLs like /v1betabeta when the base_url was already configured as v1beta.
This commit is contained in:
2026-03-05 16:33:10 +00:00
parent 3d43948dbe
commit 154b7b3b77

View File

@@ -563,13 +563,16 @@ impl GeminiProvider {
/// Determine the appropriate base URL for the model. /// Determine the appropriate base URL for the model.
/// "preview" models often require the v1beta endpoint, but newer promoted ones may be on v1. /// "preview" models often require the v1beta endpoint, but newer promoted ones may be on v1.
fn get_base_url(&self, model: &str) -> String { fn get_base_url(&self, model: &str) -> String {
// Gemini 3 and other reasoning/preview models often perform better or let base = &self.config.base_url;
// strictly require v1beta for advanced features like thought_signatures.
if model.contains("preview") || model.contains("thinking") || model.contains("gemini-3") { // If the model requires v1beta but the base is currently v1
self.config.base_url.replace("/v1", "/v1beta") if (model.contains("preview") || model.contains("thinking") || model.contains("gemini-3")) && base.ends_with("/v1") {
} else { return base.replace("/v1", "/v1beta");
self.config.base_url.clone()
} }
// 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. /// Default safety settings to avoid blocking responses.