Skip to content

Error code: 401 in Jupyterlab when trying to call OpenAI #196

Open
@nguyentuanngoc21

Description

@nguyentuanngoc21

I got Error code: 401 even when I allow all permissions for OpenAI API

I am starting to learn with the first lesson 01-intro-to-ai-agents/code_samples/01-semantic-kernel.ipynb
I tried to test it on Jupyter Lab, but then I face with 401 error at the last step. It notice that the problem occur at my line 28 (await main() )

I did try:

from openai import OpenAI

client = OpenAI(
  api_key=OPENAI_API_KEY
)

completion = client.chat.completions.create(
  model="gpt-4o-mini",
  store=True,
  messages=[
    {"role": "user", "content": "write a haiku about ai"}
  ]
)

print(completion.choices[0].message);

to test if the API available and it still works well. So I do not know what is going wrong here

Here is the screenshot of the problem

Image

FYI: I am using the newest version of Jyputer Lab and Python. All packages were also up-to-date.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions