diff --git a/crates/goose/src/providers/azure.rs b/crates/goose/src/providers/azure.rs index a35259fb..415d5b9b 100644 --- a/crates/goose/src/providers/azure.rs +++ b/crates/goose/src/providers/azure.rs @@ -64,10 +64,21 @@ impl AzureProvider { let mut base_url = url::Url::parse(&self.endpoint) .map_err(|e| ProviderError::RequestFailed(format!("Invalid base URL: {e}")))?; - base_url.set_path(&format!( - "openai/deployments/{}/chat/completions", - self.deployment_name - )); + // Get the existing path without trailing slashes + let existing_path = base_url.path().trim_end_matches('/'); + let new_path = if existing_path.is_empty() { + format!( + "/openai/deployments/{}/chat/completions", + self.deployment_name + ) + } else { + format!( + "{}/openai/deployments/{}/chat/completions", + existing_path, self.deployment_name + ) + }; + + base_url.set_path(&new_path); base_url.set_query(Some(&format!("api-version={}", self.api_version))); let response: reqwest::Response = self