Writing my first AI code using the template showing error

Dear Team,
While I was undergoing my training, I tried applying the same thing in replit which was showed in the one of the videos. But after I run the program It’s showing me an error.
Below is the template I used:
import openai
import os
import sys

openai.api_key = os.environ[‘OPENAI_API_KEY’]
except KeyError:
You haven’t set up your API key yet.

If you don’t have an API key yet, visit:

OpenAI Platform

  1. Make an account or sign in
  2. Click “View API Keys” from the top right menu.
  3. Click “Create new secret key”

Then, open the Secrets Tool and add OPENAI_API_KEY as a secret.

response = openai.ChatCompletion.create(
{“role”: “system”, “content”: “You are a helpful assistant.”},
{“role”: “user”, “content”: “Who won the world series in 2020?”},
{“role”: “assistant”, “content”: “The Los Angeles Dodgers won the World Series in 2020.”},
{“role”: “user”, “content”: “Where was it played?”}


And below is the output I received after the I run this code:

Hoping for your reply soon and with a solution to it!

Hey there, looks like the API key seems correct.
But your free credits to use aren’t there or have expired.
Please go to openai.com and choose API, then among the options after clicking top right corner drop down, search for pricing and then in the same window, check the usage tab to see if you have free credits/dollars to do so. If not, you need to buy some or sometimes using a totally new account which has never visited any openai tool like chatgpt etc., might solve it.

I am having the same problem. Did you find a solution yet?

Even if your API key is correct, it shows billing plan has expired which means that the $5 credit you receive from openAI have become $0. This is because unused credits auto-expire after a period of 3 months from the creation of your account. Create a new account on openAI with a different email ID and a different phone number to get new $5 worth of credit.

Well, create a new account with a new phone no (just take it from a friend) and log in and give the API key. make sure the account is brand new, it will work