77 "fmt"
88 "io"
99 "net/http"
10+ "net/url"
1011 "strings"
1112
1213 utils "github.com/sashabaranov/go-openai/internal"
@@ -228,10 +229,13 @@ func (c *Client) fullURL(suffix string, args ...any) string {
228229 if c .config .APIType == APITypeAzure || c .config .APIType == APITypeAzureAD {
229230 baseURL := c .config .BaseURL
230231 baseURL = strings .TrimRight (baseURL , "/" )
232+ parseURL , _ := url .Parse (baseURL )
233+ query := parseURL .Query ()
234+ query .Add ("api-version" , c .config .APIVersion )
231235 // if suffix is /models change to {endpoint}/openai/models?api-version=2022-12-01
232236 // https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/models/list?tabs=HTTP
233237 if containsSubstr ([]string {"/models" , "/assistants" , "/threads" , "/files" }, suffix ) {
234- return fmt .Sprintf ("%s/%s%s?api-version= %s" , baseURL , azureAPIPrefix , suffix , c . config . APIVersion )
238+ return fmt .Sprintf ("%s/%s%s?%s" , baseURL , azureAPIPrefix , suffix , query . Encode () )
235239 }
236240 azureDeploymentName := "UNKNOWN"
237241 if len (args ) > 0 {
@@ -240,9 +244,9 @@ func (c *Client) fullURL(suffix string, args ...any) string {
240244 azureDeploymentName = c .config .GetAzureDeploymentByModel (model )
241245 }
242246 }
243- return fmt .Sprintf ("%s/%s/%s/%s%s?api-version= %s" ,
247+ return fmt .Sprintf ("%s/%s/%s/%s%s?%s" ,
244248 baseURL , azureAPIPrefix , azureDeploymentsPrefix ,
245- azureDeploymentName , suffix , c . config . APIVersion ,
249+ azureDeploymentName , suffix , query . Encode () ,
246250 )
247251 }
248252
0 commit comments