AuthenticationError with OpenAI API: Invalid Subscription Key or Endpoint

Bright-8726 0 Reputation points
2024-02-08T20:11:41.69+00:00

Screenshot 2024-02-08 at 20.09.36

Screenshot 2024-02-08 at 20.04.35

Hello Microsoft Community,

I'm encountering an AuthenticationError while trying to use the OpenAI API for chat completion. The error message states: "AuthenticationError: Access denied due to invalid subscription key or wrong API endpoint. Make sure to provide a valid key for an active subscription and use a correct regional API endpoint for your resource." I have ensured that I am passing all the necessary parameters required for the API call (gotten from the above images), including the subscription key and the correct regional API endpoint. Here is an excerpt of the code I'm using:

openai.api_type = "azure" 
openai.api_version = "2023-08-01-preview" 
openai.api_base = os.getenv("AZURE_OPENAI_ENDPOINT") 
openai.api_key = os.getenv("AZURE_OPENAI_KEY") 

response = openai.ChatCompletion.create( engine="gpt-35-turbo-16k-model", messages=[ {"role": "system", "content": system_message}, {"role": "user", "content": user_message}, ], temperature=self.temperature, max_tokens=self.max_tokens, )

Despite providing the correct subscription key and endpoint, I'm still receiving this error. I've checked the documentation and verified that everything is set up correctly on my end. Is there anything else I should be checking or any additional steps I need to take to troubleshoot this issue? Any guidance or suggestions would be greatly appreciated. Thank you!

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,080 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Maui Rivera 240 Reputation points Microsoft Employee
    2024-02-14T05:35:46.8066667+00:00

    Hello, It looks like the API version you are using has expired. Please use the GA version or the later preview versions. Kindly see the following documentation for reference. https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#chat-completions Thanks, Maui

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.