Find answers from the community

Updated last year

OpenAI Key

At a glance

The community member is having trouble with their OpenAI API key, as their program keeps telling them that no API key was provided. The comments suggest that the community member should try setting the API key using the os.environ.get("OPENAI_KEY") method, or using a library like dotenv to load the API key from a .env file. However, there is no explicitly marked answer in the comments.

I'm using .env file to config the openai key, but the program keeps telling no API key provided, does anyone know to do with this?
W
E
2 comments
Yeah it gets crazy sometimes with the openai key
You can try setting it here
Plain Text
import openai
import os
openai.api_key = os.environ.get("OPENAI_KEY")
Maybe you need something like dotenv
Add a reply
Sign up and join the conversation on Discord