RateLimitError.OpenAIException - f"error":f"message":"Not Found(request id:20260...
🚨 错误信息
Exception litellm.RateLimitError: RateLimitError.OpenAIException - f"error":f"message":"Not Found(request id:2026011217490293643445418465881)","type":"rix_api error","param":""'code":"upstream error"l} LiteLLM Retried: 10 times
🤖 AI解决方案
错误翻译
原文:Exception litellm.RateLimitError: RateLimitError.OpenAIException - f"error":f"message":"Not Found(request id:2026011217490293643445418665881)","type":"rix_api error","param":""'code":"upstream error"l}
译文:异常 litellm.RateLimitError: OpenAIException - 错误信息:“未找到(请求ID:2026011217490293643445418665881)”,类型:“rix_api 错误”,参数:“”,代码:“上游错误”
##原因分析
这是一个 404 Not Found 错误,但被 litellm 库包装成了 RateLimitError。根本原因是:
错误发生在 litellm 尝试重试访问 OpenAI API 时(已重试 10 次 解决方案
1. 检查并修正模型名称
python
❌ 错误的模型名称示例
response = litellm.completion(
model="gpt-4-turbo", # 可能存在拼写错误
messages=[{"role": "user", "content": "Hello"}]
)✅ 正确的模型名称示例
response = litellm.completion(
model="gpt-4-turbo-preview", # 使用正确的模型名称
messages=[{"role": "user", "content": "Hello"}]
)或者使用通用的 chatgpt 模型
response = litellm.completion(
model="chatgpt", # litellm 的通用标识符
messages=[{"role": "user", "content": "Hello"}]
)
2. 检查 litellm 配置
python
import litellm设置正确的 API 基地址(如果需要)
litellm.api_base = "https://api.openai.com/v1" # 默认值,确保正确或者如果是使用其他提供商
litellm.api_base = "https://your-custom-endpoint.com/v1"
3. 验证环境变量
bash
检查 OpenAI API 密钥是否正确设置
echo $OPENAI_API_KEY或者在代码中显式设置
import os
os.environ["OPENAI_API_KEY"] = "sk-your-api-key-here"
预防措施
- 使用
litellm.get_supported_openai_params("model_name") 检查支持的模型- 定期查看 OpenAI 官方文档更新模型列表
python
import litellm
litellm.set_verbose = True # 启用详细日志
- 这会显示实际的请求URL和响应,便于快速定位端点错误
python
try:
response = litellm.completion(...)
except litellm.RateLimitError as e:
print(f"详细错误信息: {e.message}")
# 检查是否是404错误
if "Not Found" in str(e):
print("请检查模型名称或API端点配置")
except Exception as e:
print(f"其他错误: {e}")
建议立即检查: