diff --git a/src/Models/OpenAI.cs b/src/Models/OpenAI.cs index e9c7b5ed..0a83d8dc 100644 --- a/src/Models/OpenAI.cs +++ b/src/Models/OpenAI.cs @@ -155,7 +155,12 @@ namespace SourceGit.Models var client = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) }; if (!string.IsNullOrEmpty(ApiKey)) - client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}"); + { + if (Server.Contains("openai.azure.com/", StringComparison.Ordinal)) + client.DefaultRequestHeaders.Add("api-key", ApiKey); + else + client.DefaultRequestHeaders.Add("Authorization", $"Bearer {ApiKey}"); + } var req = new StringContent(JsonSerializer.Serialize(chat, JsonCodeGen.Default.OpenAIChatRequest), Encoding.UTF8, "application/json"); try