Fix GCP Vertex AI global endpoint support for Gemini 3 models (#6187)

Signed-off-by: Hugues Clouâtre <hugues@linux.com>
This commit is contained in:
Hugues Clouâtre
2026-01-23 11:18:54 -05:00
committed by GitHub
parent 698382c5ac
commit 346ff7ab84
2 changed files with 14 additions and 15 deletions
@@ -29,6 +29,8 @@ pub enum GcpLocation {
Iowa,
/// Represents the us-east5 region in Ohio
Ohio,
/// Represents the global endpoint (required for Gemini 3 models)
Global,
}
impl fmt::Display for GcpLocation {
@@ -36,18 +38,7 @@ impl fmt::Display for GcpLocation {
match self {
Self::Iowa => write!(f, "us-central1"),
Self::Ohio => write!(f, "us-east5"),
}
}
}
impl TryFrom<&str> for GcpLocation {
type Error = ModelError;
fn try_from(s: &str) -> Result<Self, Self::Error> {
match s {
"us-central1" => Ok(Self::Iowa),
"us-east5" => Ok(Self::Ohio),
_ => Err(ModelError::UnsupportedLocation(s.to_string())),
Self::Global => write!(f, "global"),
}
}
}
@@ -82,8 +73,8 @@ pub const KNOWN_MODELS: &[&str] = &[
"claude-sonnet-4@20250514",
"claude-3-5-haiku@20241022",
"claude-3-haiku@20240307",
"gemini-3-pro",
"gemini-3-flash",
"gemini-3-pro-preview",
"gemini-3-flash-preview",
"gemini-2.5-pro",
"gemini-2.5-flash",
"gemini-2.5-flash-lite",
+9 -1
View File
@@ -155,7 +155,7 @@ impl GcpVertexAIProvider {
let config = crate::config::Config::global();
let project_id = config.get_param("GCP_PROJECT_ID")?;
let location = Self::determine_location(config)?;
let host = format!("https://{}-aiplatform.googleapis.com", location);
let host = Self::build_host_url(&location);
let client = Client::builder()
.timeout(Duration::from_secs(DEFAULT_TIMEOUT_SECS))
@@ -226,6 +226,14 @@ impl GcpVertexAIProvider {
.unwrap_or_else(|| GcpLocation::Iowa.to_string()))
}
fn build_host_url(location: &str) -> String {
if location == "global" {
"https://aiplatform.googleapis.com".to_string()
} else {
format!("https://{}-aiplatform.googleapis.com", location)
}
}
/// Retrieves an authentication token for API requests.
async fn get_auth_header(&self) -> Result<String, GcpVertexAIError> {
self.auth