Hello,
I tried to run some inference in a Jupyter Notebok but I cannot manage to get a valid connection.
The documentation and looking here in the forum or online didn’t help me at all.
I added a credit card and have a balance of 10 USD.
The key is copy and pasted correctly.
In the Notebook I tried to set the key with these 3 versions:
openai.api_key = 'sk-proj-XXX'
os.environ['OPENAI_API_KEY'] = 'sk-proj-XXX'
%env OPENAI_API_KEY='sk-proj-XX'
When I try to run this code:
import os
from openai import OpenAI
client = OpenAI(
# This is the default and can be omitted
api_key=os.environ.get("OPENAI_API_KEY"),
)
gpt_model = "gpt-3.5-turbo-0125"
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model=gpt_model,
)
or this
client = OpenAI(
organization='org-XXX', # it has the actual org ID
project='proj_XXX', # it has the actual project ID
)
gpt_model = "gpt-3.5-turbo-0125"
chat_completion = client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test",
}
],
model=gpt_model,
)
I get the same error message:
AuthenticationError: Error code: 401 - {'error': {'message': "Incorrect API key provided: 'sk-proj**********************************************Ldy'. You can find your API key at https://platform.openai.com/account/api-keys.", 'type': 'invalid_request_error', 'param': None, 'code': 'invalid_api_key'}}
As I am fairly new to this. What am I doing wrong?