403: Forbidden. Trying next. FAILED — Model glm-5.1-free not allowed for this ke...
错误信息
Model glm-5.1-free failed: HTTP Error 403: Forbidden. Trying next.
FAILED — Model glm-5.1-free not allowed for this key
AI 解决方案
报错分析报告
1.错误翻译
原文:HTTP Error 403: Forbidden
译文:HTTP错误403:禁止访问
原文:Model glm-5.1-free not allowed for this key
译文:当前密钥不允许使用glm-5.1-free模型
2. 原因分析
glm-5.1-free模型的使用权限,触发服务端权限校验拦截(HTTP 403)。 glm-5.1-free模型的接口请求阶段(身份验证/权限检查环节)。3. 解决方案
# 修复示例:更换为有权限的模型(如glm-4),或更新密钥权限
import requests
api_key = "YOUR_VALID_API_KEY" # 替换为有权限的密钥
allowed_model = "glm-4" # 替换为平台允许的模型名
url = "https://api.dmxapi.cn/v1/chat/completions"
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
payload = {
"model": allowed_model,
"messages": [{"role": "user", "content": "测试请求"}]
}
response = requests.post(url, headers=headers, json=payload)
print(response.json())