No-Api-Key error. Tried multiple possible fixes. Deeplearning.ai course

This might be a repeated question. But i already explored existing questions.

I just started the DeepLearning + OpenAI course on Prompt Engineering for devs, and tried replicating what they were doing with my own api key. I keep getting the no api key error.

Code given below. Api key is cut out coz secret ofc.

import openai
import os

from dotenv import load_dotenv, find_dotenv
_ = load_dotenv(find_dotenv()) # read local .env file

openai.api_key = os.getenv("sk-Gy")
# openai.api_key=("sk-G0")
model = "gpt-3.5-turbo"

def get_completion(prompt,model='gpt-3.5-turbo'):
    messages = [{"role":"user","content": prompt}]
    response = openai.ChatCompletion.create(
    model=model,
    messages=messages,
    temperature=0,#this is the degree of randomness of the model's output
    )
    return responses.choices[0].message["content"]

text = f"""
You should express what you want a model to do by \ 
providing instructions that are as clear and \ 
specific as you can possibly make them. \ 
This will guide the model towards the desired output, \ 
and reduce the chances of receiving irrelevant \ 
or incorrect responses. Don't confuse writing a \ 
clear prompt with writing a short prompt. \ 
In many cases, longer prompts provide more clarity \ 
and context for the model, which can lead to \ 
more detailed and relevant outputs.
"""
prompt = f"""
Summarize the text delimited by triple backticks \ 
into a single sentence.
```{text}```
"""
response = get_completion(prompt)
print(response)

This is looking for an environment variable with the name of sk-Gy.

Do you have API key in .env? If so, use name from that file

Ok im kinda new to this. How do i look for the environment variable?

This code is trying to load .env in your project directory where you can put the key.

You should be able to directly set your key like this, just don’t share your code anywhere

openai.api_key = "sk-..."

Alright i tried that out. Its no longer giving the No-API-Key error. But now its giving this different error (‘You exceeded your current quota, please check your plan and billing details.’). This is literally the first time I’m using it i think where i didn’t get the no API key error. is this supposed to happen? do we start with 0 quota or something?

I made the API key today and haven’t shared with anyone

You’ll need to enter billing info here. You pay a very small amount per request, there’s no free quota.

Ah alright. I thought they give some newbie trial quota or something. Ah well. lemme try this out.