diff --git a/README.md b/README.md index dd18486..b293427 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,38 @@ GET /pool/v1/models -> catalog POST /pool/v1/chat/completions -> OpenAI-compatible ``` +## Why the balance comes out `0.0000` + +The onboarding credit is not an account feature, it is a **referral registration +reward**. The server only pays it when the invite cookie is already present at the +moment the account row is created. + +``` +GET /i/ -> Set-Cookie: ara_invite ✔ credit will land +GET /auth/oauth/github -> github ... -> ara_session -> credits 100000.0000 + +GET /auth/oauth/github -> github ... -> ara_session (no invite cookie) + -> credits 0.0000, ledger empty +``` + +Consequences, all verified against `/pool/balance`: + +* Signing up from the homepage and *then* opening an invite link does nothing — the + reward is attached to registration, not to the session. +* Re-running the flow on an account that already exists does nothing either. The + ledger keeps exactly one row: `{"kind":"invite","delta":"100000.0000"}`, + `ledger_has_more:false`. +* `ara_invite` is `HttpOnly`, so `document.cookie` shows nothing — a browser + automation "check" of the invite state is meaningless, read `/pool/balance` instead. + +Your own referral link is not rendered into the HTML; the page fetches it: + +```bash +python pool_client.py --cookie-file c.txt --no-key --my-invite --json +# "my_invite": {"code":"XXXXXXXX","link":"https://modeloc.com/i/XXXXXXXX", +# "reward_invitee":"100000","reward_invitee_enabled":true} +``` + ## Traps (each one cost real debugging time) | # | Symptom | Cause | Fix | @@ -34,6 +66,7 @@ POST /pool/v1/chat/completions -> OpenAI-compatible | 4 | `422 {"detail":[{"type":"dict_type"}]}` on `/pool/keys` | body not recognised as JSON | send `Content-Type: application/json` explicitly | | 5 | `403 error code 1010` on `/pool/v1/*` | Cloudflare TLS fingerprint blocks bare `urllib`/`requests` | `curl_cffi` with `impersonate="chrome"` | | 6 | balance looks like `0E+4` | scientific-notation zero from the API | it is a real zero — don't string-replace it into `10000` | +| 7 | `spendable 0.0000` on a fresh account | the account was created before `ara_invite` existed, or it already existed | open `/i/` **before** `/auth/oauth/github`; the account must be new | Also worth knowing: a key can exist while `/pool/v1/models` answers 200 and `chat/completions` answers 402 — the key is valid, the balance is not. diff --git a/pool_client.py b/pool_client.py index 7d75e52..95cbebf 100755 --- a/pool_client.py +++ b/pool_client.py @@ -269,6 +269,18 @@ def pool_enroll(s: Session) -> dict: return {"http": st, "body": body[:160]} +def invite_summary(s: Session) -> dict: + """Own referral link + counters (the page does exactly this fetch).""" + st, _h, body, _f = s.request(BASE + "/invite/summary", + headers={"Accept": "application/json"}) + if st != 200: + return {"http": st, "raw": body[:120]} + try: + return json.loads(body) + except Exception: + return {"http": st, "raw": body[:120]} + + def create_key(s: Session, name: str = "auto") -> dict: payload = {"name": name, "filter_mode": "all", "allowed_models": []} st, _h, body, _f = s.request(BASE + "/pool/keys", data=json.dumps(payload).encode(), @@ -328,7 +340,8 @@ def list_models(api_key: str) -> dict: # one account # --------------------------------------------------------------------------- # def run_account(cookie: str, invite: str = "", proxy: str | None = None, - want_key: bool = True, model: str = "deepseek-v4-flash") -> dict: + want_key: bool = True, model: str = "deepseek-v4-flash", + want_invite: bool = False) -> dict: s = gh_cookie_session(cookie, proxy) t0 = time.time() res: dict = {"ok": False} @@ -356,6 +369,9 @@ def run_account(cookie: str, invite: str = "", proxy: str | None = None, res["balance_after_enroll"] = bal res["spendable"] = bal.get("spendable") + if want_invite: + res["my_invite"] = invite_summary(s) + if want_key: k = create_key(s) res["key_http"] = k["http"] @@ -383,6 +399,8 @@ def main() -> int: ap.add_argument("--proxy", default=os.environ.get("HTTPS_PROXY", "")) ap.add_argument("--model", default="deepseek-v4-flash") ap.add_argument("--no-key", action="store_true", help="stop after balance") + ap.add_argument("--my-invite", action="store_true", + help="also print your own /i/ referral link (GET /invite/summary)") ap.add_argument("--json", action="store_true") args = ap.parse_args() @@ -400,7 +418,8 @@ def main() -> int: rc = 0 for i, c in enumerate(cookies, 1): - res = run_account(c, args.invite, args.proxy or None, not args.no_key, args.model) + res = run_account(c, args.invite, args.proxy or None, not args.no_key, args.model, + args.my_invite) if args.json: print(json.dumps(res)) else: