chatgpt-vercel icon indicating copy to clipboard operation
chatgpt-vercel copied to clipboard

添加可用余额展示

Open eryajf opened this issue 1 year ago • 2 comments

希望页面上增加一个可用余额的展示,该接口请求方式如下:

$ 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
      }
    ]
  }
}

eryajf avatar Mar 07 '23 15:03 eryajf

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)

thenicealex avatar Mar 08 '23 17:03 thenicealex

希望页面上增加一个可用余额的展示,该接口请求方式如下:

$ 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
      }
    ]
  }
}

请问这个你加上了吗

jing8263xiao avatar Mar 14 '23 16:03 jing8263xiao

现在可以了,两种方式,一是直接发送 key,可以发多个,换行即可。二是发送指令 查询填写的 Key 的余额,这个 Prompt 预设里有。

ourongxing avatar Mar 17 '23 10:03 ourongxing

话说,余额返回值里还有一个信息是key到期时间,这个也可以在表格呈现一下。

eryajf avatar Mar 17 '23 12:03 eryajf