先打个广告:
推荐一款不用科学上网就可以使用的ChatGPT工具:智能聊天助手
体验版入口:智能聊天助手体验版
在ChatGPT官网可以查询接口使用额度,但是官方并没有提供相应的API给开发者调用。但是可以通过破解的方式找到它的API。方法如下:
1. 使用Chrome浏览器打开https://platform.openai.com/account/usage
2. 打开开发者工具,然后刷新网页,如下就是要调用的API
3:具体的API说明:
https://api.openai.com/dashboard/billing/usage?end_date=2023-05-01&start_date=2023-04-01 其中Header中需要加入你自己的apiKey,使用crul如下:curl https://api.openai.com/dashboard/billing/usage?end_date=2023-05-01&start_date=2023-05-12 \ -H "Authorization: Bearer 你自己的APIKEY" \
说明一下请求参数:查询范围包含start_date这一天,不包含end_date这一天,前闭后开。
返回报文如下:
说明一下返回报文:cost字段对应的数值为美分,不是美元。
{
"object": "list",
"daily_costs": [
{
"timestamp": 1680825600.0,
"line_items": [
{
"name": "Instruct models",
"cost": 0.0
},
{
"name": "Chat models",
"cost": 0.0
},
{
"name": "GPT-4",
"cost": 0.0
},
{
"name": "Fine-tuned models",
"cost": 0.0
},
{
"name": "Embedding models",
"cost": 0.0
},
{
"name": "Image models",
"cost": 0.0
},
{
"name": "Audio models",
"cost": 0.0
}
]
},
{
"timestamp": 1680912000.0,
"line_items": [
{
"name": "Instruct models",
"cost": 0.0
},
{
"name": "Chat models",
"cost": 0.0
},
{
"name": "GPT-4",
"cost": 0.0
},
{
"name": "Fine-tuned models",
"cost": 0.0
},
{
"name": "Embedding models",
"cost": 0.0
},
{
"name": "Image models",
"cost": 0.0
},
{
"name": "Audio models",
"cost": 0.0
}
]
},
{
"timestamp": 1680998400.0,
"line_items": [
{
"name": "Instruct models",
"cost": 0.0
},
{
"name": "Chat models",
"cost": 0.0
},
{
"name": "GPT-4",
"cost": 0.0
},
{
"name": "Fine-tuned models",
"cost": 0.0
},
{
"name": "Embedding models",
"cost": 0.0
},
{
"name": "Image models",
"cost": 0.0
},
{
"name": "Audio models",
"cost": 0.0
}
]
},
{
"timestamp": 1681084800.0,
"line_items": [
{
"name": "Instruct models",
"cost": 0.0
},
{
"name": "Chat models",
"cost": 0.0
},
{
"name": "GPT-4",
"cost": 0.0
},
{
"name": "Fine-tuned models",
"cost": 0.0
},
{
"name": "Embedding models",
"cost": 0.0
},
{
"name": "Image models",
"cost": 0.0
},
{
"name": "Audio models",
"cost": 0.0
}
]
},
{
"timestamp": 1681171200.0,
"line_items": [
{
"name": "Instruct models",
"cost": 0.0
},
{
"name": "Chat models",
"cost": 1.7862
},
{
"name": "GPT-4",
"cost": 0.0
},
{
"name": "Fine-tuned models",
"cost": 0.0
},
{
"name": "Embedding models",
"cost": 0.0
},
{
"name": "Image models",
"cost": 0.0
},
{
"name": "Audio models",
"cost": 0.0
}
]
}
],
"total_usage": 1.7862
}