File size: 1,246 Bytes
3e18c8b
90ebe82
 
 
 
 
 
 
 
 
 
 
 
3e18c8b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

import json
from pathlib import Path

def load_json_file(filepath):
    path = Path(filepath)
    if not path.exists():
        return {}
    with path.open("r", encoding="utf-8") as f:
        return json.load(f)



import requests

def check_api_keys(api_keys_text):
    api_keys = [k.strip() for k in api_keys_text.strip().splitlines() if k.strip()]
    results = []
    for key in api_keys:
        headers = {"xi-api-key": key}
        try:
            response = requests.get("https://api.elevenlabs.io/v1/user", headers=headers)
            if response.status_code == 200:
                data = response.json()
                sub = data.get("subscription", {})
                limit = sub.get("character_limit", 0)
                used = sub.get("character_count", 0)
                remaining = limit - used
                results.append([
                    f"{key[:6]}...{key[-4:]}", f"{used:,}", f"{remaining:,}", f"{limit:,}", "✅ Hợp lệ"
                ])
            else:
                results.append([f"{key[:6]}...{key[-4:]}", "-", "-", "-", "❌ Không hợp lệ"])
        except Exception as e:
            results.append([f"{key[:6]}...{key[-4:]}", "-", "-", "-", f"⚠️ Lỗi: {str(e)}"])
    return results