chatgpt-vercel
chatgpt-vercel copied to clipboard
添加可用余额展示
希望页面上增加一个可用余额的展示,该接口请求方式如下:
$ curl -s "https://api.openai.com/dashboard/billing/credit_grants" \
--header 'Content-type: application/json' \
--header 'Authorization: Bearer api_key' | jq 这里替换api_key
{
"object": "credit_summary",
"total_granted": 18,
"total_used": 0.178104, # 已用
"total_available": 17.821896, # 剩余可用余额
"grants": {
"object": "list",
"data": [
{
"object": "credit_grant",
"id": "be32c280-ad4a-4e14-bc1a-077a32275f9e",
"grant_amount": 18,
"used_amount": 0.178104,
"effective_at": 1677628800,
"expires_at": 1688169600
}
]
}
}
import requests
headers = { 'content-type': 'application/json', 'authorization': "Bearer sk-xxxxx" }
response = requests.get('https://api.openai.com/dashboard/billing/credit_grants', headers=headers) print(response.text)
希望页面上增加一个可用余额的展示,该接口请求方式如下:
$ curl -s "https://api.openai.com/dashboard/billing/credit_grants" \ --header 'Content-type: application/json' \ --header 'Authorization: Bearer api_key' | jq 这里替换api_key { "object": "credit_summary", "total_granted": 18, "total_used": 0.178104, # 已用 "total_available": 17.821896, # 剩余可用余额 "grants": { "object": "list", "data": [ { "object": "credit_grant", "id": "be32c280-ad4a-4e14-bc1a-077a32275f9e", "grant_amount": 18, "used_amount": 0.178104, "effective_at": 1677628800, "expires_at": 1688169600 } ] } }
请问这个你加上了吗
现在可以了,两种方式,一是直接发送 key,可以发多个,换行即可。二是发送指令 查询填写的 Key 的余额
,这个 Prompt 预设里有。
话说,余额返回值里还有一个信息是key到期时间,这个也可以在表格呈现一下。