Kaushal Agarwal • over 1 year ago
GPT 4 Api Key Not Working
from openai import OpenAI
client = OpenAI(api_key="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")
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model="gpt-4",
)
It says error: raise self._make_status_error_from_response(err.response) from None
openai.AuthenticationError: Error code: 401 - {'error': {'message': 'Incorrect API key provided: sk-proj-********************************************************************************************************************************************************QbsA. You can find your API key at https://platform.openai.com/account/api-keys.', 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
Comments are closed.

3 comments
Yash Jani Manager • over 1 year ago
Hello Kaushal,
We received a notification from OpenAI indicating that a participant committed code with an API key in a public repository, which has now been disabled. I am currently working on generating a new API key. Please keep an eye on your email, as you’ll be receiving the new key soon.
Yash Jani Manager • over 1 year ago
Hello Kaushal,
I’ve sent the new API key to all participants. Please check your email.
Aryan Jain • over 1 year ago
python -u "c:\Users\maila\Desktop\test\main.py"
Authentication failed: Incorrect API key provided: sk-proj-********************************************************************************************************************************************************hzsA. You can find your API key at https://platform.openai.com/account/api-keys.