I wrote a Python program that connects to OpenAI’s ChatGPT service through their API. When I run my code, I keep getting this error message:
RateLimitError: You exceeded your current quota, please check your plan and billing details
Here’s my Python code:
#!/usr/bin/env python3
import openai
# Set up API credentials
openai.api_key = "<YOUR_API_KEY_HERE>"
# Create chat completion request
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Write a story about AI in the style of Shakespeare"}
]
)
# Display the response
print(response.choices[0].message.content)
This is confusing because I haven’t made any API calls before this. I just got my API key and this is my first attempt to use it. Is there something wrong with how I’m setting up the request? The error makes it sound like a billing issue but I expected to have some free usage available.