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:
- Make an account or sign in
- Click “View API Keys” from the top right menu.
- 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)
I am getting a rate limit error in this code. How to resolve it?
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:
- Make an account or sign in
- Click “View API Keys” from the top right menu.
- 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)
I am getting a rate limit error in this code. How to resolve it?
Traceback (most recent call last):
File “/home/runner/AICode/main.py”, line 23, in
response = openai.ChatCompletion.create(
File “/home/runner/AICode/venv/lib/python3.10/site-packages/openai/api_resources/chat_completion.py”, line 25, in create
return super().create(*args, **kwargs)
File “/home/runner/AICode/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/AICode/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/AICode/venv/lib/python3.10/site-packages/openai/api_requestor.py”, line 619, in _interpret_response
self._interpret_response_line(
File “/home/runner/AICode/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
this is the error ,I am getting