I am trying to get ChatGPT OpenAI API up and running with this little python script:
from openai import OpenAI
client = OpenAI()
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."},
{"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
]
)
print(completion.choices[0].message)
The script however gives me the following error:
RateLimitError: Error code: 429 - {'error': {'message': 'You exceeded your current quota, please check your plan and billing details. 'type': 'insufficient_quota', 'param': None, 'code':'insufficient_quota'}}
My quota however is $5, which is more than enough for this simple prompt. Is this a code problem, or a should I simply add credits to my OpenAI account?
Accoding to Rate limits, there are 5 types of rate limits:
In your case, you may hit RPM
or RPD
. You can check Rate limits in headers or your account page to confirm this.
You can use this Python code (src):
raw_response = client.chat.completions.with_raw_response.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a poetic assistant, skilled in explaining complex programming concepts with creative flair."},
{"role": "user", "content": "Compose a poem that explains the concept of recursion in programming."}
]
)
chat_completion = raw_response.parse()
response_headers = raw_response.headers
print(response_headers)