- tools/scripts/llm-key-hunter: GitHub leak hunting pipeline (hunt_*, pivot miner, two-layer verify/content caches, per-provider verification) - usable_keys: verified key vault across 12 providers (deepseek, minimax, volcanoark, longcat, codingplan, zhipu free-tier, mimo, siliconflow, etc.) - .grok/skills/llm-key-hunter: operator skill for the hunt/verify/vault flow - NewAPI channel import scripts and CDP capture helpers - Result verdict buckets (excluding multi-GB blob caches and dedup dumps)
225 lines
9.6 KiB
Python
225 lines
9.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Test Cohere and Cerebras API keys, then add working ones to NewAPI."""
|
|
|
|
import json
|
|
import urllib.request
|
|
import urllib.error
|
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
|
|
|
# ── Keys ────────────────────────────────────────────────────────
|
|
COHERE_URL = "https://api.cohere.com/compatibility/v1" # OpenAI-compatible endpoint
|
|
COHERE_KEYS = [
|
|
"ct5c9Usx0I3zvy8WlAXrHWPvXyBlIL06J7rNkSy5",
|
|
"WnFNt5UQK39iRBhjWNUdBTJZlhLM0HR3ifc0ESQa",
|
|
"MxABl5slwJzoiiHOGbO4fAVUw0Kte455V1T7jOYs",
|
|
"o6DdGd0awe4vhcOEBS4r3RJOt0PdNB4iC60lIE40",
|
|
"N2KVYbjgSfNVKZw2HSwVJCRuRqEVkpFEqCrozr22",
|
|
"fjdejHaAyGLwkWmg9OzQUsi3nQi7BQeZERcHtYcz",
|
|
]
|
|
|
|
CEREBRAS_URL = "https://api.cerebras.ai/v1"
|
|
CEREBRAS_KEYS = [
|
|
"csk-efxcjhnyc98e8mj3n36vd2hfxrjmfmc2eckk8t25dpykpdn9",
|
|
"csk-fpp82tdfhyhy955rff4w6pe59vpyrmmc633htrdwwhhwfp6e",
|
|
"csk-tkky48mnnpf83y69hcwynnkdcv6mnfwkt69vhm5tv3mmr29t",
|
|
"csk-j839dc68v5mtd323f5jfvm82rkhyny3dy8kdxyr93w2ertnt",
|
|
"csk-nxvrcft6vvk53h4j5xw488m6n6ywv6myckx6cvfvffce3fjf",
|
|
"csk-j99xk9m6kr5x5nfmkwdrm3jmctwh6eh3pvcm9ymmy293emhp",
|
|
"csk-dpvv4653fh4rk2k9y2p2nyhjvy8jw6wyp66xcrykvj33nkj4",
|
|
"csk-kppj54cwjmefpw8mj9x9w3ey9yx9yvh64jw3ek9m5prm9d3v",
|
|
"csk-fnm6jre49fr9cvhtxe2knmcpd9h6jdr3em6mr283rcmd9ftd",
|
|
"csk-2ewy2h26eeph4yex94kmjnfwwx35pdpyyxkv3j6wcj4cxc3t",
|
|
"csk-ned8jjtv48m2xdxd2v8vdrvxevh2vm6fn9kp8hkp95yj9ck2",
|
|
"csk-3rmkpjm3d5hcxf9pxjj6xy8yh3w3299p68tjnvfphm9kvx3t",
|
|
"csk-vtdn3ypfw353xmevcce9wr8w6h2evwm8kpxyh5tnwkw5v8wv",
|
|
"csk-jw6drkvjmyfwfwxpfmc8rx32v6j8kpm93ymt8vdt8nw882vd",
|
|
"csk-jfwhwetet942t4ndxjph5t83v3rrcypd48tvdce3tdk9tkh3",
|
|
"csk-kvyv3e5232wnmwtwpjwve3hwppthtj3y82wfmr3kxht8t9wm",
|
|
"csk-emyx42w88c4ddy225revxrpc6vffne5286ek5nevv5np486h",
|
|
"csk-fvy2rtd2ctn9mc8vx5nejxkwvrvwdm23crwm3ec4hyewt6yj",
|
|
"csk-m4668xx9rcvt82k8v3f8r8c896h5xkx28rycpc2y8tv6dhyv",
|
|
"csk-exh3fft5rjnc5t9wtyck9p64v6pdf2nn8h9pveh8jk6f3fte",
|
|
"csk-m4dn4epmkjeen4nj8r68h4en5f4r8ftx896kpt5jcfwwhyth",
|
|
"csk-38fjw38j8h8ct8yk4y242crcntx88w64xvncwxrpc3c8vn2f",
|
|
"csk-6ckrkdjre8d2wc5432t33ntjxtc92wmhfprd2n38x3kx6xrc",
|
|
"csk-wnx9tkpmtx6hf2cy54pyfx4wfedr6hcyw4fmynjt3xe9xfjr",
|
|
"csk-vmcpyftnpk49nmehwnnmw2yjc6h36yvv83kttm3tj523hyj9",
|
|
"csk-45rkpchch265v85mj2e85pdtyj3pm8nmdyh85wyk82pprcc3",
|
|
"csk-2cvh4kc9f58wwr4he68mtdhp23vmkmwhjnfcmcyvprvttyve",
|
|
"csk-twymk2c2nvev4jrytdteje6mr8wdt9pv24tj3mn345xm4fvy",
|
|
"csk-fd9554wf4jdn99yd8wd5j3cyhcwmn53f8vt8nwn9h5449ek5",
|
|
"csk-np8f85hn4rdpyxn8t58nr383e38h88e8w3he9f2f653df9kw",
|
|
"csk-x4npmpc6fec5ehkvvrff2cm4w2fpchmkx3y3rje2k5c835ev",
|
|
"csk-fw4ntrwrfjpj9jp6rxmte5842t6k5mx5cdv9ffrfkck9n55r",
|
|
"csk-dhfryj8rcdr656mvdkptdv29j5cmjpd5d9yh8yx8j8jcrknp",
|
|
"csk-xv6x26revypveycj6vffvf3yc4fhvx3mxwt9dy6de4xct5ty",
|
|
"csk-vy6tewrtj6th5d96tdwpv96ktmk3d5hjjt25y6tv9h2w4rwd",
|
|
]
|
|
|
|
|
|
_UA = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
|
|
|
|
|
|
def _chat_test(base_url, key, model, timeout=30):
|
|
"""Send a minimal chat completion request. Returns (ok, msg)."""
|
|
url = f"{base_url}/chat/completions"
|
|
payload = json.dumps({
|
|
"model": model,
|
|
"messages": [{"role": "user", "content": "hi"}],
|
|
"max_tokens": 5,
|
|
}).encode()
|
|
req = urllib.request.Request(url, data=payload, method="POST")
|
|
req.add_header("Authorization", f"Bearer {key}")
|
|
req.add_header("Content-Type", "application/json")
|
|
req.add_header("User-Agent", _UA)
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
raw = resp.read()
|
|
data = json.loads(raw)
|
|
content = data.get("choices", [{}])[0].get("message", {}).get("content", "")
|
|
return True, f"OK ({content[:40]})"
|
|
except urllib.error.HTTPError as e:
|
|
raw = e.read()
|
|
try:
|
|
err = json.loads(raw)
|
|
msg = err.get("error", {}).get("message", "") or err.get("message", "") or str(raw[:120])
|
|
except Exception:
|
|
msg = f"HTTP {e.code}: {raw[:120]}"
|
|
return False, msg
|
|
except Exception as e:
|
|
return False, str(e)[:120]
|
|
|
|
|
|
def _list_models(base_url, key, timeout=30):
|
|
"""List available models. Returns list of model IDs or None."""
|
|
url = f"{base_url}/models"
|
|
req = urllib.request.Request(url, method="GET")
|
|
req.add_header("Authorization", f"Bearer {key}")
|
|
req.add_header("User-Agent", _UA)
|
|
try:
|
|
with urllib.request.urlopen(req, timeout=timeout) as resp:
|
|
data = json.loads(resp.read())
|
|
return [m.get("id", "") for m in data.get("data", [])]
|
|
except Exception:
|
|
return None
|
|
|
|
|
|
def test_keys(label, base_url, keys, model):
|
|
"""Test all keys for a provider. Returns list of (key, ok, msg)."""
|
|
print(f"\n{'='*60}")
|
|
print(f" {label} ({len(keys)} keys, model={model})")
|
|
print(f"{'='*60}")
|
|
|
|
results = []
|
|
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
futures = {pool.submit(_chat_test, base_url, k, model): k for k in keys}
|
|
for future in as_completed(futures):
|
|
key = futures[future]
|
|
ok, msg = future.result()
|
|
results.append((key, ok, msg))
|
|
tag = "✅" if ok else "❌"
|
|
print(f" {tag} {key[:25]}... {msg[:80]}")
|
|
|
|
good = [k for k, ok, _ in results if ok]
|
|
bad = [k for k, ok, _ in results if not ok]
|
|
print(f"\n ✅ Working: {len(good)} / {len(keys)}")
|
|
print(f" ❌ Failed: {len(bad)} / {len(keys)}")
|
|
return results
|
|
|
|
|
|
def main():
|
|
# ── Cohere ──────────────────────────────────────────────────
|
|
print("Testing Cohere keys...")
|
|
# First try listing models with the first key to find model names
|
|
models = _list_models(COHERE_URL, COHERE_KEYS[0])
|
|
if models:
|
|
print(f" Cohere models available: {', '.join(models[:10])}")
|
|
cohere_model = models[0]
|
|
else:
|
|
print(" Could not list models, trying 'command-r-plus'")
|
|
cohere_model = "command-r-plus"
|
|
|
|
cohere_results = test_keys("Cohere", COHERE_URL, COHERE_KEYS, cohere_model)
|
|
|
|
# ── Cerebras ────────────────────────────────────────────────
|
|
print("\nTesting Cerebras keys...")
|
|
models = _list_models(CEREBRAS_URL, CEREBRAS_KEYS[0])
|
|
if models:
|
|
print(f" Cerebras models available: {', '.join(models[:15])}")
|
|
# Check if GLM-4.7 or similar is available
|
|
glm_models = [m for m in models if "glm" in m.lower()]
|
|
if glm_models:
|
|
cerebras_model = glm_models[0]
|
|
print(f" Found GLM model: {cerebras_model}")
|
|
else:
|
|
cerebras_model = models[0]
|
|
print(f" No GLM found, using: {cerebras_model}")
|
|
else:
|
|
print(" Could not list models, trying 'glm-4.7'")
|
|
cerebras_model = "glm-4.7"
|
|
|
|
cerebras_results = test_keys("Cerebras", CEREBRAS_URL, CEREBRAS_KEYS, cerebras_model)
|
|
|
|
# ── Summary ─────────────────────────────────────────────────
|
|
print(f"\n{'='*60}")
|
|
print(" FINAL SUMMARY")
|
|
print(f"{'='*60}")
|
|
|
|
cohere_good = [k for k, ok, _ in cohere_results if ok]
|
|
cerebras_good = [k for k, ok, _ in cerebras_results if ok]
|
|
|
|
print(f"\n Cohere: {len(cohere_good)}/{len(COHERE_KEYS)} keys working")
|
|
print(f" Cerebras: {len(cerebras_good)}/{len(CEREBRAS_KEYS)} keys working")
|
|
|
|
if cohere_good:
|
|
print(f"\n Working Cohere keys:")
|
|
for k in cohere_good:
|
|
print(f" {k}")
|
|
|
|
if cerebras_good:
|
|
print(f"\n Working Cerebras keys:")
|
|
for k in cerebras_good:
|
|
print(f" {k}")
|
|
|
|
# ── Add to NewAPI ───────────────────────────────────────────
|
|
if cohere_good or cerebras_good:
|
|
print(f"\n{'='*60}")
|
|
print(" Adding to NewAPI")
|
|
print(f"{'='*60}")
|
|
try:
|
|
from newapi_client import add_channel, TYPE_OPENAI
|
|
from channels_config import build_zhipuai # just to verify import works
|
|
|
|
if cohere_good:
|
|
ch = {
|
|
"type": TYPE_OPENAI,
|
|
"name": "Cohere-Pool",
|
|
"key": "\n".join(cohere_good),
|
|
"base_url": COHERE_URL,
|
|
"models": "command-r-plus,command-r,command-r-08-2024,command-a-01-2025,command-a",
|
|
"group": "default",
|
|
}
|
|
success, msg = add_channel(ch, mode="multi_to_single")
|
|
print(f" Cohere-Pool ({len(cohere_good)} keys) {'✅' if success else '❌'} {msg}")
|
|
|
|
if cerebras_good:
|
|
# Determine all available models from the first working key
|
|
all_models = _list_models(CEREBRAS_URL, cerebras_good[0]) or []
|
|
model_str = ",".join(all_models[:20]) if all_models else cerebras_model
|
|
ch = {
|
|
"type": TYPE_OPENAI,
|
|
"name": "Cerebras-Pool",
|
|
"key": "\n".join(cerebras_good),
|
|
"base_url": CEREBRAS_URL,
|
|
"models": model_str,
|
|
"group": "default",
|
|
}
|
|
success, msg = add_channel(ch, mode="multi_to_single")
|
|
print(f" Cerebras-Pool ({len(cerebras_good)} keys) {'✅' if success else '❌'} {msg}")
|
|
except Exception as e:
|
|
print(f" Error adding to NewAPI: {e}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|