@@ -1,9 +1,6 @@
11package provider
22
33import (
4− "os"
5−
6− "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
74 "github.com/openai/openai-go"
85 "github.com/openai/openai-go/azure"
96 "github.com/openai/openai-go/option"
@@ -16,27 +13,16 @@ type azureClient struct {
1613type AzureClient ProviderClient
1714
1815func newAzureClient(opts providerClientOptions) AzureClient {
19− endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT") // ex: https://foo.openai.azure.com
20− apiVersion := os.Getenv("AZURE_OPENAI_API_VERSION") // ex: 2025-04-01-preview
21−
22− if endpoint == "" || apiVersion == "" {
23− return &azureClient{openaiClient: newOpenAIClient(opts).(*openaiClient)}
16+ apiVersion := opts.extraParams["apiVersion"]
17+ if apiVersion == "" {
18+ apiVersion = "2025-01-01-preview"
2419 }
2520
2621 reqOpts := []option.RequestOption{
27− azure.WithEndpoint(endpoint, apiVersion),
28− }
29−
30− if opts.apiKey != "" || os.Getenv("AZURE_OPENAI_API_KEY") != "" {
31− key := opts.apiKey
32− if key == "" {
33− key = os.Getenv("AZURE_OPENAI_API_KEY")
34− }
35− reqOpts = append(reqOpts, azure.WithAPIKey(key))
36− } else if cred, err := azidentity.NewDefaultAzureCredential(nil); err == nil {
37− reqOpts = append(reqOpts, azure.WithTokenCredential(cred))
22+ azure.WithEndpoint(opts.baseURL, apiVersion),
3823 }
3924
25+ reqOpts = append(reqOpts, azure.WithAPIKey(opts.apiKey))
4026 base := &openaiClient{
4127 providerOptions: opts,
4228 client: openai.NewClient(reqOpts...),