Admin Name 1 month ago
admin #python

SCRIPT VERSI BARU — BISA DETEKSI FREE vs PRO Python

#!/usr/bin/env python3
"""
API Key Checker 2026 + Deteksi Free vs Pro
Telegram hanya kirim yang VALID + Full Key
"""

import sys, json, re, urllib.request, urllib.error, time
from pathlib import Path
from datetime import datetime

# Colors
RED = "\033[0;31m"; GREEN = "\033[0;32m"; YELLOW = "\033[1;33m"
BLUE = "\033[0;34m"; GRAY = "\033[0;90m"; BOLD = "\033[1m"; NC = "\033[0m"

def http_request(method, url, headers=None, data=None, timeout=12):
headers = headers or {}
headers.setdefault("User-Agent", "API-Key-Checker/2026")
try:
if data:
body = json.dumps(data).encode()
req = urllib.request.Request(url, data=body, headers=headers, method=method)
else:
req = urllib.request.Request(url, headers=headers, method=method)
with urllib.request.urlopen(req, timeout=timeout) as r:
return r.status, json.loads(r.read())
except urllib.error.HTTPError as e:
try: return e.code, json.loads(e.read())
except: return e.code, {}
except Exception as e:
return 0, {"error": str(e)}


# ========================== CHECKERS DENGAN TIER DETECTION ==========================

def check_anthropic(key):
# Test dengan model premium
status, body = http_request("POST", "https://api.anthropic.com/v1/messages",
{"x-api-key": key, "anthropic-version": "2023-06-01", "content-type": "application/json"},
{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]})
if status == 200:
return GREEN, "✅ VALID & ACTIVE (Pro)"
elif status == 401:
return RED, "❌ INVALID KEY"
elif status == 400:
msg = body.get("error", {}).get("message", "").lower()
if any(x in msg for x in ["credit", "balance", "quota", "insufficient"]):
return YELLOW, "⚠️ VALID — SALDO HABIS / FREE TIER"
return GREEN, "✅ VALID (mungkin Free/Pro)"
elif status == 429:
return YELLOW, "⚠️ VALID — RATE LIMITED (kemungkinan Free)"
else:
return RED, f"❌ ERROR {status}"


def check_openai(key):
# Cek list models dulu
status, body = http_request("GET", "https://api.openai.com/v1/models", {"Authorization": f"Bearer {key}"})
if status != 200:
if status == 401: return RED, "❌ INVALID KEY"
return RED, f"❌ ERROR {status}"
# Coba akses model premium untuk deteksi tier
premium_models = ["gpt-4o", "gpt-4.5", "o3-mini", "gpt-5"]
tier = "Free Tier"
for model in premium_models:
status2, _ = http_request("POST", "https://api.openai.com/v1/chat/completions",
{"Authorization": f"Bearer {key}", "Content-Type": "application/json"},
{"model": model, "messages": [{"role": "user", "content": "hi"}], "max_tokens": 1})
if status2 == 200:
tier = "PRO / PAID"
break
time.sleep(0.3)
return GREEN, f"✅ VALID & ACTIVE ({tier})"


def check_gemini(key):
status, body = http_request("GET", f"https://generativelanguage.googleapis.com/v1beta/models?key={key}")
if status == 200:
return GREEN, "✅ VALID & ACTIVE (Cek Google AI Studio untuk tier)"
elif status in (400, 403):
return RED, "❌ INVALID KEY"
else:
return RED, f"❌ ERROR {status}"


def check_xai(key):
status, body = http_request("GET", "https://api.x.ai/v1/models", {"Authorization": f"Bearer {key}"})
if status == 200:
return GREEN, "✅ VALID & ACTIVE (xAI Tier tergantung spend)"
elif status == 401:
return RED, "❌ INVALID KEY"
else:
return RED, f"❌ ERROR {status}"


PROVIDERS = {
"ANTHROPIC": ("Anthropic (Claude)", check_anthropic),
"OPENAI": ("OpenAI", check_openai),
"GEMINI": ("Google Gemini", check_gemini),
"XAI": ("xAI (Grok)", check_xai),
}


def load_keys(filepath):
keys = {}
path = Path(filepath)
if not path.exists():
print(f"{RED}File tidak ditemukan: {filepath}{NC}")
sys.exit(1)

for line in path.read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#"): continue
if "=" in line:
provider, _, key = line.partition("=")
provider = provider.strip().upper()
key = key.strip()
if key:
if provider in ["TELEGRAM_BOT_TOKEN", "TELEGRAM_CHAT_ID"]:
keys[provider] = key
else:
keys.setdefault(provider, []).append(key)
return keys


def send_to_telegram(bot_token, chat_id, text):
http_request("POST", f"https://api.telegram.org/bot{bot_token}/sendMessage",
{"Content-Type": "application/json"},
{"chat_id": chat_id, "text": text, "parse_mode": "HTML"})
print(f"{GREEN}✅ Hasil VALID dikirim ke Telegram{NC}")


def main():
keyfile = sys.argv[1] if len(sys.argv) > 1 else "keys.txt"
keys_dict = load_keys(keyfile)
ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

print(f"\n{BOLD}{'='*70}")
print(f" API KEY CHECKER 2026 + FREE vs PRO DETECTION")
print(f" {ts}")
print(f"{'='*70}{NC}\n")

output_lines = [f"API KEY CHECKER + TIER DETECTION - {ts}", "="*70]
tele_lines = [f"🔑 <b>API Key Checker - VALID ONLY</b>", f"🕒 {ts}", ""]

has_valid = False

for provider_id, (label, checker) in PROVIDERS.items():
provider_keys = keys_dict.get(provider_id, [])
if not provider_keys: continue

print(f"{BLUE}━━━ {label} ━━━{NC}")
output_lines.append(f"\n━━━ {label} ━━━")
tele_lines.append(f"\n<b>{label}</b>")

for i, key in enumerate(provider_keys, 1):
masked = key[:12] + "..." + key[-6:] if len(key) > 20 else key
print(f" [{i:2d}] {GRAY}{masked}{NC} → ", end="", flush=True)
color, msg = checker(key)
print(f"{color}{msg}{NC}")
output_lines.append(f" [{i:2d}] {masked} → {msg}")
if "✅" in msg or "⚠️" in msg:
tele_lines.append(f" <code>{key}</code> → {msg}")
has_valid = True
time.sleep(0.6)

# Save file
ts_file = datetime.now().strftime("%Y%m%d_%H%M%S")
out_path = Path(keyfile).parent / f"result_{ts_file}.txt"
clean_text = re.sub(r'\033\[[0-9;]*m', '', "\n".join(output_lines))
out_path.write_text(clean_text, encoding="utf-8")
print(f"\n{GREEN}📄 Hasil disimpan ke: {out_path}{NC}")

# Telegram
bot_token = keys_dict.get("TELEGRAM_BOT_TOKEN")
chat_id = keys_dict.get("TELEGRAM_CHAT_ID")

if bot_token and chat_id and has_valid:
send_to_telegram(bot_token, chat_id, "\n".join(tele_lines))
elif bot_token and chat_id:
print(f"{YELLOW}Tidak ada key VALID.{NC}")

print()


if __name__ == "__main__":
main()

Catatan Penting:

  1. OpenAI paling bagus deteksinya (karena mencoba akses model mahal).
  2. Anthropic lumayan (dari error saldo).
  3. Gemini & xAI masih agak susah dibedakan lewat API saja.

Coba jalankan dulu boss, kasih tau hasilnya seperti apa. Kalau mau aku tambah/tweak lagi (misal lebih strict atau tambah provider), bilang aja.

SCRIPT TERBARU (Update Code Block Notepad) Python

#!/usr/bin/env python3
"""
API Key Checker 2026 + Free vs Pro + Telegram Code Block
"""

import sys, json, re, urllib.request, urllib.error, time
from pathlib import Path
from datetime import datetime

# Colors
RED = "\033[0;31m"; GREEN = "\033[0;32m"; YELLOW = "\033[1;33m"
BLUE = "\033[0;34m"; GRAY = "\033[0;90m"; BOLD = "\033[1m"; NC = "\033[0m"

def http_request(method, url, headers=None, data=None, timeout=12):
headers = headers or {}
headers.setdefault("User-Agent", "API-Key-Checker/2026")
try:
if data:
body = json.dumps(data).encode()
req = urllib.request.Request(url, data=body, headers=headers, method=method)
else:
req = urllib.request.Request(url, headers=headers, method=method)
with urllib.request.urlopen(req, timeout=timeout) as r:
return r.status, json.loads(r.read())
except urllib.error.HTTPError as e:
try: return e.code, json.loads(e.read())
except: return e.code, {}
except Exception as e:
return 0, {"error": str(e)}


# ========================== CHECKERS ==========================

def check_anthropic(key):
status, body = http_request("POST", "https://api.anthropic.com/v1/messages",
{"x-api-key": key, "anthropic-version": "2023-06-01", "content-type": "application/json"},
{"model": "claude-sonnet-4-6", "max_tokens": 1, "messages": [{"role": "user", "content": "hi"}]})
if status == 200: return GREEN, "✅ VALID & ACTIVE (Pro)"
elif status == 401: return RED, "❌ INVALID KEY"
elif status == 400:
msg = body.get("error", {}).get("message", "").lower()
if any(x in msg for x in ["credit", "balance", "quota", "insufficient"]):
return YELLOW, "⚠️ VALID — SALDO HABIS / FREE"
return GREEN, "✅ VALID"
elif status == 429: return YELLOW, "⚠️ VALID — RATE LIMITED"
else: return RED, f"❌ ERROR {status}"


def check_openai(key):
status, body = http_request("GET", "https://api.openai.com/v1/models", {"Authorization": f"Bearer {key}"})
if status != 200:
if status == 401: return RED, "❌ INVALID KEY"
return RED, f"❌ ERROR {status}"
tier = "Free Tier"
premium_models = ["gpt-4o", "o3-mini", "gpt-4.5"]
for model in premium_models:
status2, _ = http_request("POST", "https://api.openai.com/v1/chat/completions",
{"Authorization": f"Bearer {key}", "Content-Type": "application/json"},
{"model": model, "messages": [{"role": "user", "content": "hi"}], "max_tokens": 1})
if status2 == 200:
tier = "PRO / PAID"
break
time.sleep(0.3)
return GREEN, f"✅ VALID & ACTIVE ({tier})"


def check_gemini(key):
status, body = http_request("GET", f"https://generativelanguage.googleapis.com/v1beta/models?key={key}")
if status == 200: return GREEN, "✅ VALID & ACTIVE"
elif status in (400, 403): return RED, "❌ INVALID KEY"
else: return RED, f"❌ ERROR {status}"


def check_xai(key):
status, body = http_request("GET", "https://api.x.ai/v1/models", {"Authorization": f"Bearer {key}"})
if status == 200: return GREEN, "✅ VALID & ACTIVE"
elif status == 401: return RED, "❌ INVALID KEY"
else: return RED, f"❌ ERROR {status}"


PROVIDERS = {
"ANTHROPIC": ("Anthropic (Claude)", check_anthropic),
"OPENAI": ("OpenAI", check_openai),
"GEMINI": ("Google Gemini", check_gemini),
"XAI": ("xAI (Grok)", check_xai),
}


def load_keys(filepath):
keys = {}
path = Path(filepath)
if not path.exists():
print(f"{RED}File tidak ditemukan: {filepath}{NC}")
sys.exit(1)

for line in path.read_text(encoding="utf-8").splitlines():
line = line.strip()
if not line or line.startswith("#"): continue
if "=" in line:
provider, _, key = line.partition("=")
provider = provider.strip().upper()
key = key.strip()
if key:
if provider in ["TELEGRAM_BOT_TOKEN", "TELEGRAM_CHAT_ID"]:
keys[provider] = key
else:
keys.setdefault(provider, []).append(key)
return keys


def send_to_telegram(bot_token, chat_id, text):
# Bungkus dengan code block notepad
final_text = f"```notepad\n{text}\n```"
http_request("POST", f"https://api.telegram.org/bot{bot_token}/sendMessage",
{"Content-Type": "application/json"},
{"chat_id": chat_id, "text": final_text, "parse_mode": "MarkdownV2"})
print(f"{GREEN}✅ Laporan VALID dikirim ke Telegram (Code Block){NC}")


def main():
keyfile = sys.argv[1] if len(sys.argv) > 1 else "keys.txt"
keys_dict = load_keys(keyfile)
ts = datetime.now().strftime("%Y-%m-%d %H:%M:%S")

print(f"\n{BOLD}{'='*75}")
print(f" API KEY CHECKER 2026 + FREE/PRO DETECTION")
print(f" {ts}")
print(f"{'='*75}{NC}\n")

output_lines = [f"API KEY CHECKER + TIER DETECTION - {ts}", "="*75]
tele_lines = [f"🔑 API Key Checker Report", f"🕒 {ts}", ""]

has_valid = False

for provider_id, (label, checker) in PROVIDERS.items():
provider_keys = keys_dict.get(provider_id, [])
if not provider_keys: continue

print(f"{BLUE}━━━ {label} ━━━{NC}")
output_lines.append(f"\n━━━ {label} ━━━")
tele_lines.append(f"\n{label}")

for i, key in enumerate(provider_keys, 1):
masked = key[:12] + "..." + key[-6:] if len(key) > 20 else key
print(f" [{i:2d}] {GRAY}{masked}{NC} → ", end="", flush=True)
color, msg = checker(key)
print(f"{color}{msg}{NC}")
output_lines.append(f" [{i:2d}] {masked} → {msg}")
if "✅" in msg or "⚠️" in msg:
tele_lines.append(f"{key} → {msg}")
has_valid = True
time.sleep(0.6)

# Save file
ts_file = datetime.now().strftime("%Y%m%d_%H%M%S")
out_path = Path(keyfile).parent / f"result_{ts_file}.txt"
clean_text = re.sub(r'\033\[[0-9;]*m', '', "\n".join(output_lines))
out_path.write_text(clean_text, encoding="utf-8")
print(f"\n{GREEN}📄 Hasil disimpan ke: {out_path}{NC}")

# Telegram
bot_token = keys_dict.get("TELEGRAM_BOT_TOKEN")
chat_id = keys_dict.get("TELEGRAM_CHAT_ID")

if bot_token and chat_id and has_valid:
send_to_telegram(bot_token, chat_id, "\n".join(tele_lines))
elif bot_token and chat_id:
print(f"{YELLOW}Tidak ada key VALID untuk dikirim.{NC}")

print()


if __name__ == "__main__":
main()

Scrap -> DL -> Merge - Upload

defaultuser.png
Admin Name
3 weeks ago

FTP Fast

defaultuser.png
Admin Name
1 month ago

STEP 5: Fix "Origin Not Allowed"

defaultuser.png
Admin Name
1 month ago

STEP 4: Cek Apakah Bisa Diakses Lewat Domain

defaultuser.png
Admin Name
1 month ago

STEP 1: Buat Project Baru di Docker Manager

defaultuser.png
Admin Name
1 month ago