Commit
·
85cfa8c
1
Parent(s):
19ed918
Update api_usage.py
Browse files- api_usage.py +17 -0
api_usage.py
CHANGED
|
@@ -30,6 +30,23 @@ def get_subscription(key):
|
|
| 30 |
try:
|
| 31 |
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if check_gpt4_availability() else body_turbo)
|
| 32 |
print (r.json())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
except Exception as e:
|
| 35 |
error_message = str(e)
|
|
|
|
| 30 |
try:
|
| 31 |
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if check_gpt4_availability() else body_turbo)
|
| 32 |
print (r.json())
|
| 33 |
+
if (r.json()["error"]):
|
| 34 |
+
if "You exceeded your current quota" in error_message:
|
| 35 |
+
rpm = "";
|
| 36 |
+
org = "";
|
| 37 |
+
quota = "No quota left."
|
| 38 |
+
elif "Your account is not active" in error_message:
|
| 39 |
+
rpm = "";
|
| 40 |
+
org = "";
|
| 41 |
+
quota = "Error: Your account is not active, please check your billing details on our website."
|
| 42 |
+
else:
|
| 43 |
+
rpm = "";
|
| 44 |
+
org = "";
|
| 45 |
+
quota = f"Unexpected Error at check_key: {error_message}"
|
| 46 |
+
else:
|
| 47 |
+
rpm = r.headers['x-ratelimit-limit-requests']
|
| 48 |
+
org = r.headers['openai-organization']
|
| 49 |
+
quota = ""
|
| 50 |
|
| 51 |
except Exception as e:
|
| 52 |
error_message = str(e)
|