chatGPT查询api的余额

代码如下:

import requests

url = 'https://api.openai.com/dashboard/billing/credit_grants'
api_key = "#填写你的key#"
headers = {
    
    
    "Authorization": "Bearer " + api_key,
    "Content-Type": "application/json"
}
response = requests.get(url, headers=headers)
print(response.text)

查询结果:
在这里插入图片描述
解释如下:

total_granted: 授予总数
total_used: 已用总量
total_available: 总可用量

记得代理,正常拿应该是拿不到的。
觉得有用的点个赞

猜你喜欢

转载自blog.csdn.net/qq_44718932/article/details/129659812