Hi, folks.
I’ve got a error message that says " 401 Incorrect API key provided: sk-Eyftb***************************************99vW."
But I’ve never used the API key, there is no such an api key on my openai_api key list.
These are the things I’ve tried to solve the issue.
generate another api key(e.g. test)
clear browser’s cache
confirmed api key that I’m actually using in .env.local with the openai_api_key on openai’s api page.
confirmed there are no typos or space on openai_api_key code.
I expect that the prior error was resolved by discovering the source of incorrect authentication credentials that were being employed in making API calls.
What software platform is being used?
For example, you might write some python code taken right from the API Reference, using the openai python module.
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
)
print(completion.choices[0].message)
If on Windows, how does this code know what API key to use? Environment variable.
Start typing “environment” into the Windows 10 start menu, and you get:
Under system variables, look for an existing API key, or place your key created from the account’s API key management into a new one: