mirror of
https://github.com/langbot-app/LangBot.git
synced 2026-06-10 15:56:03 +00:00
feat(!usage): 支持查看账户额度剩余
This commit is contained in:
13
pkg/utils/credit.py
Normal file
13
pkg/utils/credit.py
Normal file
@@ -0,0 +1,13 @@
|
||||
# OpenAI账号免费额度剩余查询
|
||||
import requests
|
||||
|
||||
|
||||
def fetch_credit_data(api_key: str) -> dict:
|
||||
"""OpenAI账号免费额度剩余查询"""
|
||||
resp = requests.get(
|
||||
url="https://api.openai.com/dashboard/billing/credit_grants",
|
||||
headers={
|
||||
"Authorization": "Bearer {}".format(api_key),
|
||||
}
|
||||
)
|
||||
return resp.json()
|
||||
Reference in New Issue
Block a user