
智能摘要 AI
文章描述了一个API请求错误的情况,具体表现为尝试获取API使用情况时收到403错误,提示请求必须使用会话密钥(即只能从浏览器发起),而当前使用的为秘密密钥。深入调查后发现,请求接口和授权头信息无误,但问题出在密钥类型不匹配。文中提到,后续可能需要通过浏览器登录OpenAI来获取有效的会话密钥以查询信用额度或令牌余额。此外,账单查询功能仍可正常使用。
错误表现
2023-04-01 15:53:47,158 [ERROR] [openai_func.py:81] 获取API使用情况失败:API request failed with status code 403: {
"error": {
"message": "Your request to GET /dashboard/billing/credit_grants must be made with a session key (that is, it can only be made from the browser). You made it with the following key type: secret.",
"type": "server_error",
"param": null,
"code": null
}
}
深入调查
目前请求的接口未变:https://api.openai.com/dashboard/billing/credit_grants,header的authorization:Bearer sess-NY9FavD0q4VpFRfN3HF*****************

可能只有通过测试对话的方式来查询秘钥是否有效了,不过依然可以进行账单查询。后续想要查询token的余额,可能需要跳转Open AI登录获取




