wavespeed.ai autoreg: GitHub OAuth + Turnstile pipeline, key extraction, measured stats
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Check WaveSpeed keys: model catalogue, chat completion, media generation.
|
||||
|
||||
Usage: WS_KEYS=keys.txt python ws_keycheck.py
|
||||
Env: WS_LLM (default https://llm.wavespeed.ai/v1), WS_MEDIA (default https://api.wavespeed.ai/api/v3)
|
||||
"""
|
||||
import json
|
||||
import os
|
||||
|
||||
import requests
|
||||
|
||||
LLM = os.environ.get("WS_LLM", "https://llm.wavespeed.ai/v1")
|
||||
MEDIA = os.environ.get("WS_MEDIA", "https://api.wavespeed.ai/api/v3")
|
||||
CHAT_MODEL = os.environ.get("WS_CHAT_MODEL", "qwen/qwen3.7-flash")
|
||||
MEDIA_MODEL = os.environ.get("WS_MEDIA_MODEL", "wavespeed-ai/flux-schnell")
|
||||
|
||||
|
||||
def hdr(key):
|
||||
return {"Authorization": "Bearer " + key, "Content-Type": "application/json"}
|
||||
|
||||
|
||||
def check(key):
|
||||
out = {"key": key[:16] + "...", "models": None, "chat": None, "media": None}
|
||||
try:
|
||||
r = requests.get(LLM + "/models", headers=hdr(key), timeout=30)
|
||||
out["models"] = r.status_code
|
||||
except Exception as e:
|
||||
out["models"] = repr(e)[:60]
|
||||
try:
|
||||
r = requests.post(LLM + "/chat/completions", headers=hdr(key), timeout=60,
|
||||
json={"model": CHAT_MODEL, "max_tokens": 10,
|
||||
"messages": [{"role": "user", "content": "say ok"}]})
|
||||
out["chat"] = r.status_code
|
||||
if r.status_code != 200:
|
||||
out["chat_body"] = r.text[:120]
|
||||
except Exception as e:
|
||||
out["chat"] = repr(e)[:60]
|
||||
try:
|
||||
r = requests.post(MEDIA + "/" + MEDIA_MODEL, headers=hdr(key), timeout=90,
|
||||
json={"prompt": "a red cube", "size": "512*512"})
|
||||
out["media"] = r.status_code
|
||||
except Exception as e:
|
||||
out["media"] = repr(e)[:60]
|
||||
return out
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
keys = [l.strip() for l in open(os.environ.get("WS_KEYS", "keys.txt")) if l.strip()]
|
||||
alive = []
|
||||
for k in keys:
|
||||
res = check(k)
|
||||
print(json.dumps(res, ensure_ascii=False), flush=True)
|
||||
if res["chat"] == 200 or res["media"] == 200:
|
||||
alive.append(k)
|
||||
print("alive: %d/%d" % (len(alive), len(keys)))
|
||||
Reference in New Issue
Block a user