Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests, re
|
| 3 |
-
from api_usage import get_subscription, check_key_availability, check_key_ant_availability, check_ant_rate_limit, check_key_gemini_availability, check_key_azure_availability, get_azure_status, get_azure_deploy, check_key_mistral_availability, check_mistral_quota, check_key_replicate_availability, check_key_aws_availability, check_key_or_availability, check_key_or_limits, check_gcp_anthropic, check_groq_status, check_nai_status, check_elevenlabs_status
|
| 4 |
|
| 5 |
async def sort_key(key, rate_limit, claude_model):
|
| 6 |
_key = key.strip()
|
|
@@ -10,7 +10,13 @@ async def sort_key(key, rate_limit, claude_model):
|
|
| 10 |
|
| 11 |
if re.match(re.compile("sk-ant-api03-[a-zA-Z0-9\-_]{93}AA"), _key) or (_key.startswith("sk-ant-") and len(_key) == 93) or (len(_key) == 89 and re.match(re.compile("sk-[a-zA-Z0-9]{86}"), _key)):
|
| 12 |
return await get_key_ant_info(_key, rate_limit, claude_model)
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
if _key.startswith("sk-"):
|
| 15 |
return get_key_oai_info(_key)
|
| 16 |
|
|
@@ -23,6 +29,9 @@ async def sort_key(key, rate_limit, claude_model):
|
|
| 23 |
if (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
|
| 24 |
return get_key_replicate_info(_key)
|
| 25 |
|
|
|
|
|
|
|
|
|
|
| 26 |
if len(_key.split(':')) == 2 and _key.split(':')[1].islower() and len(_key.split(':')[1]) == 32 and "openai.azure.com" not in _key.split(':')[1]:
|
| 27 |
endpoint = f"{_key.split(':')[0]}.openai.azure.com"
|
| 28 |
api_key = _key.split(':')[1]
|
|
@@ -56,36 +65,48 @@ async def sort_key(key, rate_limit, claude_model):
|
|
| 56 |
def get_key_oai_info(key):
|
| 57 |
# Return a dictionary containing key information
|
| 58 |
session = requests.Session()
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
return info_dict
|
| 90 |
|
| 91 |
async def get_key_ant_info(key, rate_limit, claude_model):
|
|
@@ -98,14 +119,20 @@ async def get_key_ant_info(key, rate_limit, claude_model):
|
|
| 98 |
"filter_response": "",
|
| 99 |
"requests_per_minute": "",
|
| 100 |
"tokens_per_minute": "",
|
|
|
|
|
|
|
| 101 |
"tier": "",
|
| 102 |
-
"concurrent_rate_limit": ""
|
|
|
|
| 103 |
|
| 104 |
info_dict["status"] = key_avai[1]
|
| 105 |
info_dict["filter_response"] = key_avai[2]
|
| 106 |
info_dict["requests_per_minute"] = key_avai[3] + ("" if key_avai[3] == "" else f" ({key_avai[4]} left)")
|
| 107 |
info_dict["tokens_per_minute"] = key_avai[5] + ("" if key_avai[5] == "" else f" ({key_avai[6]} left)")
|
|
|
|
|
|
|
| 108 |
info_dict["tier"] = key_avai[7]
|
|
|
|
| 109 |
|
| 110 |
if rate_limit:
|
| 111 |
rate = await check_ant_rate_limit(key, claude_model)
|
|
@@ -272,7 +299,45 @@ def get_key_elevenlabs_info(key):
|
|
| 272 |
"user_info": key_avai[1],
|
| 273 |
"voices_info": key_avai[2]}
|
| 274 |
return info_dict
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 275 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 276 |
def not_supported(key):
|
| 277 |
info_dict = {#"account_name": "",
|
| 278 |
"key_type": "Not supported",
|
|
@@ -284,7 +349,7 @@ def clear_inputs(text):
|
|
| 284 |
|
| 285 |
with gr.Blocks() as demo:
|
| 286 |
gr.Markdown('''
|
| 287 |
-
# OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter/Vertex AI(GCP Anthropic)/Groq/NovelAI/ElevenLabs API Key Status Checker
|
| 288 |
|
| 289 |
*(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
|
| 290 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests, re
|
| 3 |
+
from api_usage import get_subscription, check_key_availability, get_orgs_me, check_key_ant_availability, check_ant_rate_limit, check_key_gemini_availability, check_key_azure_availability, get_azure_status, get_azure_deploy, check_key_mistral_availability, check_mistral_quota, check_key_replicate_availability, check_key_aws_availability, check_key_or_availability, check_key_or_limits, check_gcp_anthropic, check_groq_status, check_nai_status, check_elevenlabs_status, check_xai_status, check_stability_status, check_deepseek_status
|
| 4 |
|
| 5 |
async def sort_key(key, rate_limit, claude_model):
|
| 6 |
_key = key.strip()
|
|
|
|
| 10 |
|
| 11 |
if re.match(re.compile("sk-ant-api03-[a-zA-Z0-9\-_]{93}AA"), _key) or (_key.startswith("sk-ant-") and len(_key) == 93) or (len(_key) == 89 and re.match(re.compile("sk-[a-zA-Z0-9]{86}"), _key)):
|
| 12 |
return await get_key_ant_info(_key, rate_limit, claude_model)
|
| 13 |
+
|
| 14 |
+
if re.match(re.compile(r"sk-[a-zA-Z0-9]{48}"), _key) and len(_key) == 51 and 'T3BlbkFJ' not in _key:
|
| 15 |
+
return get_key_stability_info(_key)
|
| 16 |
+
|
| 17 |
+
if re.match(re.compile(r"sk-[a-f0-9]{32}"), _key):
|
| 18 |
+
return get_key_deepseek_info(_key)
|
| 19 |
+
|
| 20 |
if _key.startswith("sk-"):
|
| 21 |
return get_key_oai_info(_key)
|
| 22 |
|
|
|
|
| 29 |
if (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
|
| 30 |
return get_key_replicate_info(_key)
|
| 31 |
|
| 32 |
+
if _key.startswith("xai-"):
|
| 33 |
+
return get_key_xai_info(_key)
|
| 34 |
+
|
| 35 |
if len(_key.split(':')) == 2 and _key.split(':')[1].islower() and len(_key.split(':')[1]) == 32 and "openai.azure.com" not in _key.split(':')[1]:
|
| 36 |
endpoint = f"{_key.split(':')[0]}.openai.azure.com"
|
| 37 |
api_key = _key.split(':')[1]
|
|
|
|
| 65 |
def get_key_oai_info(key):
|
| 66 |
# Return a dictionary containing key information
|
| 67 |
session = requests.Session()
|
| 68 |
+
|
| 69 |
+
status, org_data = check_key_availability(session, key)
|
| 70 |
+
|
| 71 |
+
info_dict = {
|
| 72 |
+
"key_type": "OpenAI",
|
| 73 |
+
"key_availability": True if status else False,
|
| 74 |
+
"gpt4_availability": "",
|
| 75 |
+
"gpt4_32k_availability": "",
|
| 76 |
+
"default_org": "",
|
| 77 |
+
"org_description": "",
|
| 78 |
+
"organization": "",
|
| 79 |
+
"models": "",
|
| 80 |
+
"requests_per_minute": "",
|
| 81 |
+
"tokens_per_minute": "",
|
| 82 |
+
"quota": "",
|
| 83 |
+
"all_models": ""
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
if not status:
|
| 87 |
+
return info_dict
|
| 88 |
+
|
| 89 |
+
if status == 403:
|
| 90 |
+
status_me, orgs_me = get_orgs_me(session, key)
|
| 91 |
+
if status_me == 200:
|
| 92 |
+
org_data = orgs_me
|
| 93 |
+
|
| 94 |
+
subscription_info = get_subscription(key, session, org_data)
|
| 95 |
+
|
| 96 |
+
# Update the info_dict with subscription details
|
| 97 |
+
info_dict.update({
|
| 98 |
+
"gpt4_availability": subscription_info["has_gpt4"],
|
| 99 |
+
"gpt4_32k_availability": subscription_info["has_gpt4_32k"],
|
| 100 |
+
"default_org": subscription_info["default_org"],
|
| 101 |
+
"org_description": subscription_info["org_description"],
|
| 102 |
+
"organization": subscription_info["organization"],
|
| 103 |
+
"models": subscription_info["models"],
|
| 104 |
+
"requests_per_minute": subscription_info["rpm"],
|
| 105 |
+
"tokens_per_minute": subscription_info["tpm"],
|
| 106 |
+
"quota": subscription_info["quota"],
|
| 107 |
+
"all_models": subscription_info["all_models"]
|
| 108 |
+
})
|
| 109 |
+
|
| 110 |
return info_dict
|
| 111 |
|
| 112 |
async def get_key_ant_info(key, rate_limit, claude_model):
|
|
|
|
| 119 |
"filter_response": "",
|
| 120 |
"requests_per_minute": "",
|
| 121 |
"tokens_per_minute": "",
|
| 122 |
+
"tokens_input_per_minute": "",
|
| 123 |
+
"tokens_output_per_minute": "",
|
| 124 |
"tier": "",
|
| 125 |
+
"concurrent_rate_limit": "",
|
| 126 |
+
"models": ""}
|
| 127 |
|
| 128 |
info_dict["status"] = key_avai[1]
|
| 129 |
info_dict["filter_response"] = key_avai[2]
|
| 130 |
info_dict["requests_per_minute"] = key_avai[3] + ("" if key_avai[3] == "" else f" ({key_avai[4]} left)")
|
| 131 |
info_dict["tokens_per_minute"] = key_avai[5] + ("" if key_avai[5] == "" else f" ({key_avai[6]} left)")
|
| 132 |
+
info_dict["tokens_input_per_minute"] = key_avai[8] + ("" if key_avai[8] == "" else f" ({key_avai[9]} left)")
|
| 133 |
+
info_dict["tokens_output_per_minute"] = key_avai[10] + ("" if key_avai[10] == "" else f" ({key_avai[11]} left)")
|
| 134 |
info_dict["tier"] = key_avai[7]
|
| 135 |
+
info_dict["models"] = key_avai[12]
|
| 136 |
|
| 137 |
if rate_limit:
|
| 138 |
rate = await check_ant_rate_limit(key, claude_model)
|
|
|
|
| 299 |
"user_info": key_avai[1],
|
| 300 |
"voices_info": key_avai[2]}
|
| 301 |
return info_dict
|
| 302 |
+
|
| 303 |
+
def get_key_xai_info(key):
|
| 304 |
+
key_avai = check_xai_status(key)
|
| 305 |
+
info_dict = {#"account_name": "",
|
| 306 |
+
"key_type": "xAI Grok",
|
| 307 |
+
"key_availability": key_avai[0],
|
| 308 |
+
"key_status": "",
|
| 309 |
+
"models": ""}
|
| 310 |
+
if key_avai[0]:
|
| 311 |
+
info_dict['key_status'] = key_avai[1]
|
| 312 |
+
info_dict['models'] = key_avai[2]
|
| 313 |
+
return info_dict
|
| 314 |
|
| 315 |
+
def get_key_stability_info(key):
|
| 316 |
+
key_avai = check_stability_status(key)
|
| 317 |
+
info_dict = {#"account_name": "",
|
| 318 |
+
"key_type": "Stability AI",
|
| 319 |
+
"key_availability": key_avai[0],
|
| 320 |
+
"account_info": "",
|
| 321 |
+
"credits": "",
|
| 322 |
+
"models": ""}
|
| 323 |
+
if key_avai[0]:
|
| 324 |
+
info_dict['account_info'] = key_avai[1]
|
| 325 |
+
info_dict['credits'] = key_avai[2]
|
| 326 |
+
info_dict['models'] = key_avai[3]
|
| 327 |
+
return info_dict
|
| 328 |
+
|
| 329 |
+
def get_key_deepseek_info(key):
|
| 330 |
+
key_avai = check_deepseek_status(key)
|
| 331 |
+
info_dict = {#"account_name": "",
|
| 332 |
+
"key_type": "deepseek",
|
| 333 |
+
"key_availability": key_avai[0],
|
| 334 |
+
"balance": "",
|
| 335 |
+
"models": ""}
|
| 336 |
+
if key_avai[0]:
|
| 337 |
+
info_dict['models'] = key_avai[1]
|
| 338 |
+
info_dict['balance'] = key_avai[2]
|
| 339 |
+
return info_dict
|
| 340 |
+
|
| 341 |
def not_supported(key):
|
| 342 |
info_dict = {#"account_name": "",
|
| 343 |
"key_type": "Not supported",
|
|
|
|
| 349 |
|
| 350 |
with gr.Blocks() as demo:
|
| 351 |
gr.Markdown('''
|
| 352 |
+
# OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter/Vertex AI(GCP Anthropic)/Groq/NovelAI/ElevenLabs/xAI/Stability/Deepseek API Key Status Checker
|
| 353 |
|
| 354 |
*(Based on shaocongma, CncAnon1, su, Drago, kingbased key checkers)*
|
| 355 |
|