Skip to content

Commit 10d70f3

Browse files
committed
fix: properly handle Azure URL construction with query params
1 parent ed56dcd commit 10d70f3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

async-openai/src/chat_with_trait.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,16 @@ impl<'c, C: Config> ChatWithTrait<'c, C> {
3030
&self,
3131
request: CreateChatCompletionRequest,
3232
) -> Result<CreateChatCompletionResponse, OpenAIError> {
33-
// Prepare the request
34-
let url = reqwest::Url::parse(&self.client.config.url("/chat/completions"))
33+
// Prepare the request - config.url() returns the full URL
34+
let url_str = self.client.config.url("/chat/completions");
35+
let mut url = reqwest::Url::parse(&url_str)
3536
.map_err(|e| OpenAIError::InvalidArgument(format!("Invalid URL: {}", e)))?;
3637

38+
// Add query parameters from config
39+
for (key, value) in self.client.config.query() {
40+
url.query_pairs_mut().append_pair(key, value);
41+
}
42+
3743
// Serialize request body
3844
let body = serde_json::to_vec(&request)
3945
.map_err(|e| OpenAIError::InvalidArgument(format!("Failed to serialize request: {}", e)))?;

0 commit comments

Comments
 (0)