add wavespeed autoreg pipeline + keycheck + measured stats; env-driven config, no secrets

This commit is contained in:
reform
2026-11-01 03:46:57 +03:00
parent f47a77f655
commit 131cda56cd
6 changed files with 370 additions and 21 deletions
+8 -4
View File
@@ -1,5 +1,9 @@
*.jsonl
*.txt
bank.jsonl
used_gh.txt
keys.txt
grants_keys.txt
*.session
__pycache__/
.2cap_key
fbkey.txt
*.pyc
.env
cookies.json
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Reform / Gothbreach
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+94 -17
View File
@@ -1,24 +1,101 @@
# wavespeed-autoreg
# WaveSpeed.ai autoreg
Autoreg for [WaveSpeed AI](https://wavespeed.ai). Signup is **GitHub OAuth only**, so this worker logs into a
GitHub pool account over plain HTTP (with TOTP), walks the OAuth consent, then solves the Turnstile on `/sign-in`.
Automated account registration on [wavespeed.ai](https://wavespeed.ai) via GitHub OAuth,
with API-key extraction and trial-credit harvesting.
## Economics (checked 2026-11-01)
* Trial credit **$1 per account**, but it is **not granted to every account**: 1 of 60 got `balance=1`,
59 got `$0`. Rule not confirmed yet (suspect: 1 grant per egress subnets / device).
* Key format `wsk_live_...`. Two different surfaces:
* `https://llm.wavespeed.ai/v1` - OpenAI-compatible LLM gateway (qwen3-coder, qwen3-vl-235b, aion-2.0).
A funded key returns 200 here; an empty key returns `403 group_balance_not_enough`.
* media API - keys only activate after the first top-up, so the trial is useless for images/video.
## What it does
One account = one pass of the pipeline:
1. **GitHub login** — direct egress (datacenter IP triggers `sessions/verified-device`,
residential/hosted-but-trusted IPs do not).
2. **WaveSpeed sign-in hop** — `GET /center/default/github/login?cf-turnstile-response=<token>`.
The page is protected by Cloudflare Turnstile (sitekey `0x4AAAAAADkE2yCxK2sRF0Q4`,
action `login`), solved through 2captcha `TurnstileTaskProxyless` (~$0.003 per account,
~15-25 s).
3. **OAuth authorize + callback** → dashboard session cookies.
4. **Balance read** from `/dashboard` (`Current credit balance`) and **API key creation**
via `POST /center/default/api/v1/accesskey/create` with `{"name": "..."}`.
5. Result appended to `bank.jsonl`: `{gh_login, balance, key, cookies, egress, secs}`.
## Measured behaviour (2026-11-01)
| metric | value |
|---|---|
| accounts processed | 170 |
| API keys created | 120 |
| keys with `$1` trial balance | 7 (4 unique accounts) |
| `$0` balance | 113 |
| no-callback (GitHub side blocked) | 50 |
| time per account | 20-80 s |
| cost per account | ~$0.003 (captcha) |
Key findings:
- **The `$1` trial is granted probabilistically** (~3-8%), not by IP, subnet, geo or
timing. Same egress IP produced both `$1` and `$0` accounts minutes apart, and a
second signup from an already-used IP sometimes still got `$1`. Volume is the only lever.
- **Turnstile is mandatory** — without a valid token the hop endpoint returns non-302.
2captcha `TurnstileTaskProxyless` is accepted; solving inside headless Camoufox is not.
- **Key creation has no gate** — a key is issued even with `$0` balance, but every call
then fails with `403 Insufficient balance` (LLM) or `400 Insufficient credits` (media).
## API surface of an issued key
```
LLM : https://llm.wavespeed.ai/v1/models
https://llm.wavespeed.ai/v1/chat/completions (130 models)
Media : https://api.wavespeed.ai/api/v3/<model> e.g. wavespeed-ai/flux-schnell
```
Cheapest models (price per 1M tokens, input/output):
| model | input | output |
|---|---|---|
| qwen/qwen3.7-flash | $0.03 | $0.13 |
| openai/gpt-5-nano | $0.05 | $0.40 |
| anthropic/claude-haiku-5.5 | $0.10 | $0.50 |
| openai/gpt-6-luna | $0.10 | $0.50 |
$1 of trial credit ≈ 33M input tokens on qwen3.7-flash.
## Usage
```bash
pip install -r requirements.txt
export WS_TWOCAP_KEY=<2captcha key>
export WS_PROXY=http://user:pass@host:8888 # egress for the WaveSpeed leg
export WS_GH_POOL=/path/to/gh_pool.json # [{"login","password","totp"}, ...]
export WS_BANK=bank.jsonl
export WS_USED=used_gh.txt
python wavespeed/ws_autoreg.py 25 # process 25 fresh accounts
WS_KEYS=keys.txt python wavespeed/ws_keycheck.py
```
`gh_pool.json` is a list of GitHub accounts with `login`, `password` and `totp` secret.
The script skips logins already listed in `WS_USED`.
## Files
* `ws_farm.py` - `python ws_farm.py 25` -> N accounts, resumable via `used_gh.txt`, results appended to `bank.jsonl`.
## Env
```
TWOCAPTCHA_KEY=... # Turnstile solver (sitekey is public: 0x4AAAAAADkE2yCxK2sRF0Q4)
PROXY_AUTH=user:pass # auth for the HTTP CONNECT proxy pool
WS_BOXES=1.2.3.4,5.6.7.8 # egress hosts, port 8888 assumed
WS_HOME=/path/to/workdir
wavespeed/ws_autoreg.py registration pipeline (GitHub OAuth + Turnstile + key creation)
wavespeed/ws_keycheck.py key validation: catalogue, chat completion, media generation
```
Requires `pyotp` for GitHub 2FA.
## Notes / pitfalls
- `verified-device` on the GitHub login means the account needs an e-mail code — use
another egress for the GitHub leg or a verified account, retrying does not help.
- GitHub returns `422` on `/login/oauth/authorize` when the login session is not actually
established (the earlier redirect chain was cut short) — always verify the login URL
before the OAuth hop.
- Console output must stay ASCII: Windows `cp1252` raises `UnicodeEncodeError` and kills
the worker mid-wave.
- Relative steps of the pipeline are independent: a failure at the callback stage still
burns the GitHub login, so log every attempt to `WS_USED`.
## License
MIT — see `LICENSE`.
+3
View File
@@ -0,0 +1,3 @@
requests>=2.31
PySocks>=1.7.1
pyotp>=2.9
+189
View File
@@ -0,0 +1,189 @@
#!/usr/bin/env python3
"""WaveSpeed.ai account autoregistration.
Flow per account:
1. GitHub login (direct egress) + OAuth authorize
2. WaveSpeed sign-in hop: GET /center/default/github/login?cf-turnstile-response=<token>
(Turnstile solved via 2captcha, task TurnstileTaskProxyless)
3. OAuth callback -> dashboard cookies
4. Read trial balance, create API key (POST /center/default/api/v1/accesskey/create)
Result: JSONL bank with {login, balance, key, cookies, egress}, keys usable on
LLM : https://llm.wavespeed.ai/v1/chat/completions
Media : https://api.wavespeed.ai/api/v3/<model>
Config via env:
WS_TWOCAP_KEY 2captcha client key (required)
WS_PROXY egress for the WaveSpeed leg, e.g. http://user:pass@host:8888 (optional)
WS_GH_POOL path to GitHub accounts JSON (list of {login,password,totp}) (required)
WS_BANK output JSONL path (default bank.jsonl)
WS_USED used-logins file (default used_gh.txt)
"""
import json
import os
import re
import sys
import time
import uuid
import requests
import pyotp
UA = ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36")
SITE = os.environ.get("WS_TURNSTILE_SITEKEY", "0x4AAAAAADkE2yCxK2sRF0Q4")
SIGNIN = "https://wavespeed.ai/sign-in"
KEY2CAP = os.environ.get("WS_TWOCAP_KEY", "")
PROXY = os.environ.get("WS_PROXY", "")
BANK = os.environ.get("WS_BANK", "bank.jsonl")
USED = os.environ.get("WS_USED", "used_gh.txt")
POOL = os.environ.get("WS_GH_POOL", "gh_pool.json")
def proxy_map():
if not PROXY:
return {}
return {"http": PROXY, "https": PROXY}
def turnstile_token():
"""Solve Cloudflare Turnstile for the sign-in page via 2captcha."""
s = requests.Session()
r = s.post("https://api.2captcha.com/createTask", json={
"clientKey": KEY2CAP,
"task": {
"type": "TurnstileTaskProxyless",
"websiteURL": SIGNIN,
"websiteKey": SITE,
"action": "login",
"userAgent": UA,
},
}, timeout=30).json()
tid = r.get("taskId")
if not tid:
raise RuntimeError("2captcha createTask: %s" % str(r)[:200])
for _ in range(40):
time.sleep(5)
res = s.post("https://api.2captcha.com/getTaskResult",
json={"clientKey": KEY2CAP, "taskId": tid}, timeout=30).json()
if res.get("status") == "ready":
return res["solution"]["token"]
if res.get("errorId"):
raise RuntimeError("2captcha error: %s" % str(res)[:200])
raise RuntimeError("turnstile timeout")
def github_login(acc):
"""Log into GitHub. Returns (session, status)."""
gs = requests.Session()
gs.headers.update({"User-Agent": UA, "Accept-Language": "en-US,en;q=0.9"})
r = gs.get("https://github.com/login", timeout=45)
m = re.search(r'name="authenticity_token" value="([^"]+)"', r.text)
if not m:
return None, "no-csrf"
r = gs.post("https://github.com/session", data={
"authenticity_token": m.group(1),
"login": acc["login"],
"password": acc["password"],
"commit": "Sign in",
"return_to": "",
}, timeout=45, allow_redirects=True)
if "verified-device" in r.url:
return None, "verified-device"
if "two-factor" in r.url:
if not acc.get("totp"):
return None, "2fa-no-secret"
m2 = re.search(r'name="authenticity_token" value="([^"]+)"', r.text)
r = gs.post("https://github.com/sessions/two-factor", data={
"authenticity_token": m2.group(1) if m2 else "",
"otp": pyotp.TOTP(acc["totp"]).now(),
}, timeout=45, allow_redirects=True)
if "two-factor" in r.url:
return None, "2fa-fail"
if "verified-device" in r.url:
return None, "verified-device"
if "github.com/login" in r.url:
return None, "login-fail"
return gs, "ok"
def register(acc):
t0 = time.time()
out = {"gh_login": acc["login"], "ts": int(t0)}
gs, st = github_login(acc)
out["gh"] = st
if not gs:
return out
ws = requests.Session()
ws.headers.update({"User-Agent": UA, "Accept-Language": "en-US,en;q=0.9"})
px = proxy_map()
if px:
ws.proxies.update(px)
try:
out["egress"] = requests.get("https://api.ipify.org?format=json",
proxies=px, timeout=25).json().get("ip")
except Exception:
out["egress"] = "?"
tok = turnstile_token()
r = ws.get("https://wavespeed.ai/center/default/github/login",
params={"cf-turnstile-response": tok}, allow_redirects=False, timeout=60)
if r.status_code != 302:
out["err"] = "hop %s" % r.status_code
return out
r2 = gs.get(r.headers["location"], timeout=45, allow_redirects=False)
loc = r2.headers.get("location", "")
if "login/oauth/authorize" in r2.url:
m3 = re.search(r'name="authenticity_token" value="([^"]+)"', r2.text)
r2 = gs.post(r2.url, data={"authenticity_token": m3.group(1) if m3 else "",
"authorize": "1"}, timeout=45, allow_redirects=False)
loc = r2.headers.get("location", "")
if not loc.startswith("https://wavespeed.ai"):
out["err"] = "no-callback(%s)" % (loc[:50] or r2.status_code)
return out
r3 = ws.get(loc, timeout=60, allow_redirects=True)
out["landed"] = r3.url
if "dashboard" not in r3.url:
out["err"] = "landed " + r3.url[:80]
return out
d = ws.get("https://wavespeed.ai/dashboard", timeout=60)
m4 = re.search(r'Current credit balance.{0,220}?\$\s*<!-- -->([0-9.]+)', d.text, re.S)
out["balance"] = m4.group(1) if m4 else None
kr = ws.post("https://wavespeed.ai/center/default/api/v1/accesskey/create",
json={"name": "k" + uuid.uuid4().hex[:6]}, timeout=60)
try:
out["key"] = (kr.json().get("data") or {}).get("key")
except Exception:
out["key_error"] = kr.text[:120]
out["cookies"] = {c.name: c.value for c in ws.cookies if c.name.startswith("wavespeed")}
out["secs"] = round(time.time() - t0, 1)
return out
def main(n):
pool = json.load(open(POOL, encoding="utf-8"))
used = set(open(USED).read().split()) if os.path.exists(USED) else set()
todo = [a for a in pool if a["login"] not in used]
print("pool: %d todo: %d" % (len(pool), len(todo)), flush=True)
for acc in todo[:n]:
try:
out = register(acc)
except Exception as e:
out = {"gh_login": acc["login"], "error": repr(e)[:200]}
with open(BANK, "a", encoding="utf-8") as f:
f.write(json.dumps(out, ensure_ascii=False) + "\n")
with open(USED, "a") as f:
f.write(acc["login"] + "\n")
print(json.dumps({k: out.get(k) for k in
("gh_login", "balance", "key", "egress", "gh", "err")},
ensure_ascii=False), flush=True)
if __name__ == "__main__":
main(int(sys.argv[1]) if len(sys.argv) > 1 else 10)
+55
View File
@@ -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)))