For a month I cannot connect anymore using AZURE.AI.OPENAI
I updated my package to the latest 2.0
And either I have an error that it can not find a model, either it can not connect.
Setup is quite very simple :
builder.Services.AddSingleton<OpenAIClient>(_ => new OpenAIClient("OpenAI"));
Config is
"ConnectionStrings": {
"OpenAI": "Key=sk-proj-Mykry"
}
And here an example of a ChatCompletion method
[HttpPost("translate-text")]
public ChatCompletion TranslateText(TranslationRequest request)
{
var client = _openAiClient.GetChatClient(DefaultModel);
var messages = new List<ChatMessage>();
messages.Add($"Describe this image. Language should be {request.TargetLanguage}.");
if (request.Prompts != null)
{
messages.Add($"Translate the following text from {request.SourceLanguage} to {request.TargetLanguage} =>");
messages.Add(new OpenAI.Chat.UserChatMessage(string.Join("n", request.Prompts)));
}
var options = BuildBaseOptions((OpenAiBaseRequest)request);
messages.AddRange(GetSystemMessages("You are a helpful creative translator.", request.SystemMessages, request.ResponseFormat));
var results = client.CompleteChatAsync(messages, options);
// Incorrect API key provided: OpenAI. You can find your API key at
// https://platform.openai.com/account/api-keys.)'
return results.Result.Value;
}
The returns stuck as API Key provided is Incorrect, I already tried to instantiate openclient directly with the API key, I deleted and recreated 10 times my keys, the last ones were project keys. But no way… And it was working perfectly before the launch of GPT4-o.
Did any one had the same issue ? or have an idea what is going wrong ?
Laurent Lequenne is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.