flashvayne / chatgpt-spring-boot-starter

a chatgpt starter based on Openai Official Apis.
MIT License
225 stars 55 forks source link

是否能提供查询API余额的功能? #14

Closed StarCode000 closed 1 year ago

StarCode000 commented 1 year ago

这是一个python示例:

import requests

session_key = "Bearer sess-xxxx"
url = "https://api.openai.com/dashboard/billing/credit_grants"
headers = {
    "Content-Type": "application/json",
    f"Authorization": f"Bearer {session_key}"
}

response = requests.get(url, headers=headers)
print(response.json())
flashvayne commented 1 year ago

OK. I will add this recently. Thanks for your comment.

StarCode000 commented 1 year ago

可以从另一个相关的网址查询到每个月的限额:https://api.openai.com/dashboard/billing/subscription 并且使用这个网址可以查询到每个月的使用量:https://api.openai.com/dashboard/billing/usage?end_date=2023-05-01&start_date=2023-04-01

flashvayne commented 1 year ago

Thanks for your comments. I checked these APIs, but maybe they should not be added here because they are from the request in browser and not included in the OpenAI API Document. So I don't think they are stable enough. If one day these APIs fail, it may cause some accidents.