Commit
·
04764e4
1
Parent(s):
3b9b623
Update api_usage.py
Browse files- api_usage.py +7 -4
api_usage.py
CHANGED
|
@@ -28,7 +28,12 @@ def get_subscription(key):
|
|
| 28 |
org = ""
|
| 29 |
quota = ""
|
| 30 |
try:
|
| 31 |
-
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if check_gpt4_availability() else body_turbo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
except Exception as e:
|
| 33 |
error_message = str(e)
|
| 34 |
if "You exceeded your current quota" in error_message:
|
|
@@ -43,9 +48,7 @@ def get_subscription(key):
|
|
| 43 |
rpm = "";
|
| 44 |
org = "";
|
| 45 |
quota = f"Unexpected Error at check_key: {error_message}"
|
| 46 |
-
|
| 47 |
-
org = r.headers['openai-organization']
|
| 48 |
-
quota = ""
|
| 49 |
#has_payment_method = results["has_payment_method"]
|
| 50 |
# hard_limit = results["hard_limit"]
|
| 51 |
#soft_limit_usd = results["soft_limit_usd"]
|
|
|
|
| 28 |
org = ""
|
| 29 |
quota = ""
|
| 30 |
try:
|
| 31 |
+
r = requests.post(queryUrl, headers=headers, json=body_gpt4 if check_gpt4_availability() else body_turbo)
|
| 32 |
+
if (r.headers['x-ratelimit-limit-requests']):
|
| 33 |
+
rpm = r.headers['x-ratelimit-limit-requests']
|
| 34 |
+
org = r.headers['openai-organization']
|
| 35 |
+
quota = ""
|
| 36 |
+
|
| 37 |
except Exception as e:
|
| 38 |
error_message = str(e)
|
| 39 |
if "You exceeded your current quota" in error_message:
|
|
|
|
| 48 |
rpm = "";
|
| 49 |
org = "";
|
| 50 |
quota = f"Unexpected Error at check_key: {error_message}"
|
| 51 |
+
|
|
|
|
|
|
|
| 52 |
#has_payment_method = results["has_payment_method"]
|
| 53 |
# hard_limit = results["hard_limit"]
|
| 54 |
#soft_limit_usd = results["soft_limit_usd"]
|