限制规则
- 每个 API key 有每分钟请求次数限制
- 不同模型可能有不同的频率限制
- 超过限制会收到
429 Too Many Requests错误
遇到限速怎么办
收到 429 错误时:- 等一下再试 — 响应头
Retry-After会告诉你等几秒 - 加指数退避 — 每次重试间隔翻倍(1s → 2s → 4s → 8s)
- 控制并发 — 减少同时发出的请求数量
提高限额
如果默认限额不够用,可以:- 充值更多额度(余额越高,限额通常越宽松)
- 联系客服申请提高限额
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Anyone — one API key to access all AI models
了解 Anyone 的请求频率限制和应对方式。
429 Too Many Requests 错误{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"code": "rate_limit_exceeded"
}
}
Retry-After 会告诉你等几秒import time
import openai
def call_with_retry(client, max_retries=3, **kwargs):
for i in range(max_retries):
try:
return client.chat.completions.create(**kwargs)
except openai.RateLimitError:
wait = 2 ** i # 指数退避
time.sleep(wait)
raise Exception("重试次数用尽")
