Console problem

import openai
import os
import sys

try:
openai.api_key = os.environ[‘OPENAI_API_KEY’]
except KeyError:
sys.stderr.write(“”"
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.
“”")
exit(1)

response = openai.ChatCompletion.create(
model=“gpt-3.5-turbo”,
messages=[
{“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?”}
]
)

print(response)

Hi @shreyajain53964,

We are looking into this issue. It would be really helpful if you could attach a screenshot of the Open AI page.
go to platfrom.openai.com ---- go to API ---- click on personal ---- go to view API Keys ---- on the left hand side, click on Usage.
After clicking on Usage, send me the screenshot of the whole window.

prob

i attached the rec here please check it once . the prob is that the code shows error after inserting secret key

Hi @shreyajain53964 ,

Apologies for the delay caused from our end.
Regarding the API issue, many users may encounter an error if they do not have sufficient credits to access the OpenAI API keys.
If you are facing this problem, it is crucial to verify the usage of your API key, particularly if it has a balance of $0 or if it has expired.
In such cases, it is recommended to create a new account using a different phone number and a different email ID.
By doing so, you will receive $5 worth of credits, which will remain valid for three months.