superdup95 commited on
Commit
d7d26ad
1 Parent(s): 98feccc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -17
app.py CHANGED
@@ -1,31 +1,42 @@
1
  import gradio as gr
2
  import requests
3
- from api_usage import get_subscription, check_key_availability, check_key_ant_availability, 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
4
 
5
  def sort_key(key):
6
  _key = key.strip()
 
 
 
 
7
  if _key.startswith("sk-ant-"):
8
- return get_key_ant_info(_key)
9
- elif _key.startswith("sk-"):
10
- return get_key_oai_info(_key)
11
- elif _key.startswith("AIzaSy"):
 
 
12
  return get_key_gemini_info(_key)
13
- elif (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
 
14
  return get_key_replicate_info(_key)
15
- elif len(_key.split(':')) == 2 and _key.split(':')[1].islower() and len(_key.split(':')[1]) == 32 and "openai.azure.com" not in _key.split(':')[1]:
 
16
  endpoint = f"{_key.split(':')[0]}.openai.azure.com"
17
  api_key = _key.split(':')[1]
18
- return get_key_azure_info(endpoint, api_key)
19
- elif "openai.azure.com" in _key.split(';')[0]:
 
20
  endpoint = _key.split(';')[0]
21
  api_key = _key.split(';')[1]
22
- return get_key_azure_info(endpoint, api_key)
23
- elif _key.startswith("AKIA") and len(_key.split(':')[0]) == 20 and _key.split(':')[0].isupper():
 
24
  return get_key_aws_info(_key)
25
- elif len(_key) == 32:
26
- return get_key_mistral_info(_key)
27
- else:
28
- return not_supported(_key)
 
29
 
30
  def get_key_oai_info(key):
31
  # Return a dictionary containing key information
@@ -157,11 +168,39 @@ def get_key_aws_info(key):
157
  info_dict['admin'] = key_avai[3]
158
  info_dict['quarantine'] = key_avai[4]
159
  info_dict['iam_full_access'] = key_avai[5]
160
- info_dict['billing'] = key_avai[8]
161
  info_dict['claude_v2_enabled_region'] = key_avai[6]
162
  info_dict['claude_sonnet_enabled_region'] = key_avai[7]
163
  info_dict['cost_and_usage'] = key_avai[8]
164
  return info_dict
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  def not_supported(key):
167
  info_dict = {#"account_name": "",
@@ -174,7 +213,7 @@ def clear_inputs(text):
174
 
175
  with gr.Blocks() as demo:
176
  gr.Markdown('''
177
- # OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude API Key Status Checker
178
 
179
  *(Based on shaocongma, CncAnon1, Drago and kingbased key checkers)*
180
 
 
1
  import gradio as gr
2
  import requests
3
+ from api_usage import get_subscription, check_key_availability, check_key_ant_availability, 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
4
 
5
  def sort_key(key):
6
  _key = key.strip()
7
+
8
+ if _key.startswith("sk-or-v1-"):
9
+ return get_key_openrouter_info(_key)
10
+
11
  if _key.startswith("sk-ant-"):
12
+ return get_key_ant_info(_key)
13
+
14
+ if _key.startswith("sk-"):
15
+ return get_key_oai_info(_key)
16
+
17
+ if _key.startswith("AIzaSy"):
18
  return get_key_gemini_info(_key)
19
+
20
+ if (_key.startswith("r8_") and len(_key) == 40) or (_key.islower() and len(_key) == 40):
21
  return get_key_replicate_info(_key)
22
+
23
+ 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]:
24
  endpoint = f"{_key.split(':')[0]}.openai.azure.com"
25
  api_key = _key.split(':')[1]
26
+ return get_key_azure_info(endpoint, api_key)
27
+
28
+ if "openai.azure.com" in _key.split(';')[0]:
29
  endpoint = _key.split(';')[0]
30
  api_key = _key.split(';')[1]
31
+ return get_key_azure_info(endpoint, api_key)
32
+
33
+ if _key.startswith("AKIA") and len(_key.split(':')[0]) == 20 and _key.split(':')[0].isupper():
34
  return get_key_aws_info(_key)
35
+
36
+ if len(_key) == 32:
37
+ return get_key_mistral_info(_key)
38
+
39
+ return not_supported(_key)
40
 
41
  def get_key_oai_info(key):
42
  # Return a dictionary containing key information
 
168
  info_dict['admin'] = key_avai[3]
169
  info_dict['quarantine'] = key_avai[4]
170
  info_dict['iam_full_access'] = key_avai[5]
 
171
  info_dict['claude_v2_enabled_region'] = key_avai[6]
172
  info_dict['claude_sonnet_enabled_region'] = key_avai[7]
173
  info_dict['cost_and_usage'] = key_avai[8]
174
  return info_dict
175
+
176
+ def get_key_openrouter_info(key):
177
+ key_avai = check_key_or_availability(key)
178
+ info_dict = {#"account_name": "",
179
+ "key_type": "OpenRouter",
180
+ "key_availability": key_avai[0],
181
+ "is_free_tier": "",
182
+ "usage": "",
183
+ "balance": "",
184
+ "limit": "",
185
+ "limit_remaining": "",
186
+ "rate_limit_per_minite": "",
187
+ "4_turbo_per_request_tokens_limit": "",
188
+ "sonnet_per_request_tokens_limit": "",
189
+ "opus_per_request_tokens_limit": ""}
190
+ if key_avai[0]:
191
+ models_info = check_key_or_limits(key)
192
+ info_dict['is_free_tier'] = key_avai[1]['is_free_tier']
193
+ info_dict['limit'] = key_avai[1]['limit']
194
+ info_dict['limit_remaining'] = key_avai[1]['limit_remaining']
195
+ info_dict['usage'] = f"${format(key_avai[1]['usage'], '.4f')}"
196
+ info_dict['balance'] = f"${format(models_info[0], '.4f')}"
197
+ info_dict['rate_limit_per_minite'] = key_avai[2]
198
+ info_dict['4_turbo_per_request_tokens_limit'] = models_info[1]['openai/gpt-4-turbo-preview']
199
+ info_dict['sonnet_per_request_tokens_limit'] = models_info[1]['anthropic/claude-3-sonnet:beta']
200
+ info_dict['opus_per_request_tokens_limit'] = models_info[1]['anthropic/claude-3-opus:beta']
201
+ else:
202
+ info_dict['usage'] = key_avai[1]
203
+ return info_dict
204
 
205
  def not_supported(key):
206
  info_dict = {#"account_name": "",
 
213
 
214
  with gr.Blocks() as demo:
215
  gr.Markdown('''
216
+ # OpenAI/Anthropic/Gemini/Azure/Mistral/Replicate/AWS Claude/OpenRouter API Key Status Checker
217
 
218
  *(Based on shaocongma, CncAnon1, Drago and kingbased key checkers)*
219