Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions crates/goose/src/providers/formats/gcpvertexai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,25 +29,16 @@ 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 {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
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"),
}
}
}
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 9 additions & 1 deletion crates/goose/src/providers/gcpvertexai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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
Expand Down