-1
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:
  
  https://platform.openai.com/signup

  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)


And i got this error back:

îș§ python3 main.py
Traceback (most recent call last):
  File "/home/runner/AI-Code-1/main.py", line 23, in \<module\>
    response = openai.ChatCompletion.create(
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_resources/chat_completion.py", line 25, in create
    return super().create(\*args, \*\*kwargs)
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_resources/abstract/engine_api_resource.py", line 153, in create
    response, \_, api_key = requestor.request(
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 226, in request
    resp, got_stream = self.\_interpret_response(result, stream)
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 619, in \_interpret_response
    self.\_interpret_response_line(
  File "/home/runner/AI-Code-1/venv/lib/python3.10/site-packages/openai/api_requestor.py", line 679, in \_interpret_response_line
    raise self.handle_error_response(
openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details.
exit status 1
desertnaut
  • 57,590
  • 26
  • 140
  • 166
RDK
  • 1
  • Btw the api key i put was newly generated one – RDK Aug 30 '23 at 08:55
  • 1
    "You exceeded your current quota, please check your plan and billing details" - seems pretty clear cut. Also, this question is off topic as quota / billing stuff is not a programming issue. – l4mpi Aug 30 '23 at 09:17

1 Answers1

-1

As per your logs:

openai.error.RateLimitError: You exceeded your current quota, please check your plan and billing details
Pierluigi
  • 1,048
  • 2
  • 9
  • 16
  • It seems i have to set up some credits. I actually created a new free account and though i would get some free credits to use for a time but it seems i was wrong.Thank you – RDK Aug 30 '23 at 09:16