#[Python] Get Usage for Account

6 messages · Page 1 of 1 (latest)

winged depot
#

Hey, I have a question about the python API again, is it possible to get the accounts usage for the current month?
GPT-3 solutions dont seem to work ^^

print("Total API Requests this month:", usage['data'][0]['api']['usage'])```
Thats what it suggested
low cliff
#

I don't believe they have a way to do it via the api

winged depot
#

Oh that would be sad

winged depot
#
    api_url = "https://api.openai.com/v1/organizations/{0}]/users".format(org_id)
    headers =  {"Content-Type":"application/json", "authority":"api.openai.com", "scheme":"https", "path":"/v1/organizations/{0}/users", "authorization":"Bearer {1}".format(org_id, api_key)}
    response = requests.post(api_url, data="", headers=headers)
    response.json()```
I have found this, it doenst seem to like my org-id tho
winged depot
#
    api_url = "https://api.openai.com/v1/organizations/{0}".format(org_id)
    headers =  {"Content-Type":"application/json", "authorization":"Bearer {0}".format(api_key)}
    response = requests.get(api_url, headers=headers)
    response_json = response.content.decode('utf-8')
    json_data = json.loads(response_json)
    print(json_data)
    return json_data```
Current code
```json
{'object': 'organization', 'id': 'org-XXXXX', 'created': 1663017908, 'title': 'Personal', 'name': 'user-XXXXX', 'description': 'Personal org for XXX@gmail.com', 'personal': True, 'is_default': True, 'role': 'owner'}```