@@ -1,9 +1,6 @@
1package provider
1package provider
6− "github.com/Azure/azure-sdk-for-go/sdk/azidentity"
7 "github.com/openai/openai-go"
4 "github.com/openai/openai-go"
8 "github.com/openai/openai-go/azure"
5 "github.com/openai/openai-go/azure"
9 "github.com/openai/openai-go/option"
6 "github.com/openai/openai-go/option"
@@ -16,27 +13,16 @@ type azureClient struct {
16type AzureClient ProviderClient
13type AzureClient ProviderClient
18func newAzureClient(opts providerClientOptions) AzureClient {
15func newAzureClient(opts providerClientOptions) AzureClient {
19− endpoint := os.Getenv("AZURE_OPENAI_ENDPOINT") // ex: https://foo.openai.azure.com
16+ apiVersion := opts.extraParams["apiVersion"]
20− apiVersion := os.Getenv("AZURE_OPENAI_API_VERSION") // ex: 2025-04-01-preview
17+ if apiVersion == "" {
21−
18+ apiVersion = "2025-01-01-preview"
22− if endpoint == "" || apiVersion == "" {
23− return &azureClient{openaiClient: newOpenAIClient(opts).(*openaiClient)}
26 reqOpts := []option.RequestOption{
21 reqOpts := []option.RequestOption{
27− azure.WithEndpoint(endpoint, apiVersion),
22+ azure.WithEndpoint(opts.baseURL, apiVersion),
30− if opts.apiKey != "" || os.Getenv("AZURE_OPENAI_API_KEY") != "" {
33− key = os.Getenv("AZURE_OPENAI_API_KEY")
35− reqOpts = append(reqOpts, azure.WithAPIKey(key))
36− } else if cred, err := azidentity.NewDefaultAzureCredential(nil); err == nil {
37− reqOpts = append(reqOpts, azure.WithTokenCredential(cred))
25+ reqOpts = append(reqOpts, azure.WithAPIKey(opts.apiKey))
40 base := &openaiClient{
26 base := &openaiClient{
41 providerOptions: opts,
27 providerOptions: opts,
42 client: openai.NewClient(reqOpts...),
28 client: openai.NewClient(reqOpts...),