Once you have downloaded the files (helper_functions.py) from our website,
open it:
Replace this piece of code:
#Get the OpenAI API key from the .env file
load_dotenv('.env', override=True)
openai_api_key = os.getenv('OPENAI_API_KEY')
# Set up the OpenAI client
client = OpenAI(api_key=openai_api_key)
With this:
### Add your key as a string
openai_api_key = "Add your key in here"
# Set up the OpenAI client
client = OpenAI(api_key=openai_api_key)
As the code indicates, you need to add your open API key to it.
Thanks to @Mubsi and my various research, I found the solutions. I also realised that one needs to have an OpenAI account, and an API Key, AND a payment arrangement with OpenAI (ChatGPT told me the amount is very small for someone like me), to run helper_functions in local environment.
Thanks all.
Hello @ribusgan
You can use gemini free api is good enough for testing personal stuff (you have API request limits per minute)
from google import genai
client = genai.Client(api_key="YOUR_API_KEY")
response = client.models.generate_content(
model="gemini-2.0-flash",
contents="Explain how AI works in a few words",
)
print(response.text)