AuthenticationError: Error code: 401

That’s not going to work. Sending the string and not your actual key.

The OpenAI python client will use an environment variable API_KEY_OPENAI automatically - when you set it in the OS or the environment.

It was just two days ago I produced an AI response telling someone how to set an environment variable: https://chatgpt.com/share/b2c99472-e3ee-4067-ab2c-f39a7e29c0ed

There is no need to put anything as parameters in the client, unless you want a particular timeout or are billing to a different organization you are a member of.

1 Like