Spaces:
Paused
Paused
| 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 | |