|
|
import gradio as gr |
|
|
import requests, re |
|
|
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 |
|
|
) |
|
|
|
|
|
async def sort_key(key, rate_limit, claude_model): |
|
|
_key = key.strip() |
|
|
|
|
|
return info_dict |
|
|
|
|
|
async def sort_keys(keys_text, rate_limit, claude_model): |
|
|
""" |
|
|
Split input by newline and lookup each key in turn. |
|
|
Returns a mapping from each key to its info dict. |
|
|
""" |
|
|
keys = [k.strip() for k in keys_text.splitlines() if k.strip()] |
|
|
results = {} |
|
|
for k in keys: |
|
|
results[k] = await sort_key(k, rate_limit, claude_model) |
|
|
return results |
|
|
|
|
|
def clear_inputs(text): |
|
|
return "" |
|
|
|
|
|
with gr.Blocks() as demo: |
|
|
gr.Markdown(''' |
|
|
# Multi-Key API Key Status Checker |
|
|
|
|
|
Enter one API key per line; this tool will check each in turn. |
|
|
''') |
|
|
|
|
|
claude_options = [ |
|
|
'claude-3-haiku-20240307', |
|
|
'claude-3-sonnet-20240229', |
|
|
'claude-3-opus-20240229', |
|
|
'claude-3-5-sonnet-20240620', |
|
|
'claude-3-5-sonnet-20241022', |
|
|
'claude-3-5-haiku-20241022' |
|
|
] |
|
|
|
|
|
with gr.Row(): |
|
|
with gr.Column(): |
|
|
key_input = gr.Textbox( |
|
|
lines=5, |
|
|
placeholder="sk-... or AKIA...", |
|
|
label="API Keys (one per line)" |
|
|
) |
|
|
claude_model = gr.Dropdown( |
|
|
claude_options, |
|
|
value="claude-3-haiku-20240307", |
|
|
label="Claude API model", |
|
|
info="Model for filter_response and concurrent rate check" |
|
|
) |
|
|
rate_limit = gr.Checkbox( |
|
|
label="Check concurrent rate limit (Anthropic Claude)" |
|
|
) |
|
|
with gr.Row(): |
|
|
clear_button = gr.Button("Clear") |
|
|
submit_button = gr.Button("Submit", variant="primary") |
|
|
with gr.Column(): |
|
|
info = gr.JSON(label="API Keys Information", open=True) |
|
|
|
|
|
clear_button.click(fn=clear_inputs, inputs=[key_input], outputs=[key_input]) |
|
|
submit_button.click( |
|
|
fn=sort_keys, |
|
|
inputs=[key_input, rate_limit, claude_model], |
|
|
outputs=[info], |
|
|
api_name="sort_keys" |
|
|
) |
|
|
|
|
|
demo.launch() |
|
|
|