我是 ChatGPT OpenAI API 的新手,并尝试使用这个小 python 脚本启动并运行它:
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)
但是脚本给了我以下错误:
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'}}
我的配额是 5 美元,对于这个简单的提示来说已经足够了。这是代码问题,还是我应该简单地将积分添加到我的 OpenAI 帐户?
根据速率限制,有5种速率限制:
就您而言,您可以点击
RPM
或 RPD
。您可以检查标题中的速率限制或您的帐户页面来确认这一点。
您可以使用此Python代码(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)