semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

Error: Access denied: The request is not authorized, HTTP status: 401

Open ShaoHans opened this issue 2 years ago • 7 comments

when I upgrade the Microsoft.SemanticKernel from 0.13.277.1-preview to 0.13.442.1-preview , the samples which I write two weeks ago cannot work , it said : ### Error: Access denied: The request is not authorized, HTTP status: 401。But when I use 0.13.442.1-preview,the samples can work very well ,what happen ? the code is below: ` await Console.Out.WriteLineAsync("please input your OpenAI key ..."); var key = Console.ReadLine(); var sk = Kernel.Builder.Build(); sk.Config.AddOpenAITextCompletionService("OpenAI_davinci", "text-davinci-003", key!);

string summarizeBlurbFlex = """ Summarize the following text in two sentences or less. ---begin text--- {{$INPUT}} ---end text--- """;

var mySummarizeFunction = sk.CreateSemanticFunction(summarizeBlurbFlex, maxTokens: 1000); var myOutput = await mySummarizeFunction.InvokeAsync("a long text ...."); Console.WriteLine(myOutput); `

ShaoHans avatar May 09 '23 14:05 ShaoHans

I'm getting the same error when calling kernel.Memory.SaveInformationAsync() after updating from 0.13.277.1-preview to 0.13.442.1-preview. Error: Access denied: The request is not authorized, HTTP status: 401 Detail: Incorrect API key provided: text-emb**********-002. You can find your API key at https://platform.openai.com/account/api-keys. Status: 401 (Unauthorized) ErrorCode: invalid_api_key

Pelias2525 avatar May 09 '23 19:05 Pelias2525

@ShaoHans , sorry you ran into this. The AddOpenAITextCompletionService changed during latest package. We are working on a process to call out breaking changes so you will know between nuget releases what is new and what has changed. @shawncal

evchaki avatar May 09 '23 20:05 evchaki

The same issue happened to me.

yaohaizh avatar May 10 '23 04:05 yaohaizh

same issue with 0.13.442.1-preview.

MikeYeager avatar May 11 '23 21:05 MikeYeager

@ShaoHans , sorry you ran into this. The AddOpenAITextCompletionService changed during latest package. We are working on a process to call out breaking changes so you will know between nuget releases what is new and what has changed. @shawncal

yes, the AddOpenAITextCompletionService parameter order has changed on 0.13.442.1-preview version , but it's difficult found @MikeYeager @RickGoGo @yaohaizh @Pelias2525 image

ShaoHans avatar May 12 '23 14:05 ShaoHans

Thank you. That was the issue for me. I didn't even notice it. Removing the first (now unnecessary) parameter from the call fixed it for me.

MikeYeager avatar May 12 '23 15:05 MikeYeager