Files
camb-autoreg/README.md
T
2026-11-01 19:27:26 +03:00

114 lines
5.3 KiB
Markdown

# camb-autoreg
Autoreg for [studio.camb.ai](https://studio.camb.ai) — dubbing / TTS service with a refillable free plan.
## Economics (verified on live accounts, 2026-11-01)
* Free product: **5000 credits**, `is_refill_based: true` (monthly refill).
* Balance: `GET https://client.camb.ai/payments/credits/team/<team_id>` -> `{"credits_left":5000.0,"is_free_plan":true}`.
* Dub job (job_type 1) = 550 credits -> ~9 dubs per account. TTS phrase ~3 credits.
* 100k credits pack = $50 -> 1 credit ~= $0.0005 -> free account ~= $2.5 of API value.
## Flow
1. `https://studio.camb.ai/public/onboarding` is the only signup entry (`/signup`, `/register` return 404 shells).
2. Form: `input[name=name]`, `input[type=email]`, `input[type=password]` (10+ chars, upper+lower+digit+symbol), consent checkbox (Radix `button[role=checkbox]` — click by bbox).
3. Turnstile sitekey `0x4AAAAAAB7HkZD89uSr-6VZ`, token lands in `input[name=cf-turnstile-response]` (~752 chars). Wait for it before submit.
4. `POST https://client.camb.ai/uservault/auth/signup` -> `200 {"payload":{"access_token":"..."}}`; token works before email verification.
5. Mail from `help@camb.ai`, subject `Email Verification`. **Code is 6 alphanumeric chars** (`LSQX01`), not digits.
6. `PATCH /uservault/users/verification/mail/verify?verification_code=<CODE>` -> `{"verified": true}`.
7. Onboarding "Who are you?" -> Skip -> `/workspace/<team_id>/home`.
8. team_id: `POST /uservault/auth/refresh-token` (credentials include) -> `payload.access_token` -> `GET /v1/teams/` with bearer -> `payload.teams[0].id`.
9. Key: `/workspace/<team_id>/api-keys` -> Create New API Key -> `input[name=api-key-name]` -> Create Secret Key -> read 30+ char value.
10. Working call: `POST https://client.camb.ai/apis/tts-stream` with header `x-api-key` and body
`{"text","language":"en-us","voice_id":147320,"speech_model":"mars-flash","output_configuration":{"format":"wav"}}`.
Credits spent come back in `x-credits-required`.
## Pitfalls
* No Turnstile token -> `400 "Turnstile token not found"` on both signup and login. Browser farm only.
* Verification mail quota: `GET /uservault/users/verification/mail/quota-status` -> `can_send:false`, `block_type:"soft_block"`, ~2 min window. Do not hammer Resend.
* Match the submit button by exact text `create account`; a loose "sign up" match hits the Google button.
* Clear cookies AND localStorage before signup, otherwise the onboarding form may not render.
* `pg.close()` on the last tab kills CDP Chrome; reattach with `ensure_chrome(port, prof)`.
* Vercel Security Checkpoint: curl/curl_cffi get `429` + HTML stub; only real Chrome over CDP passes. The API host `client.camb.ai` is reachable directly — do recon there.
## Files
* `farm.py` — worker: signup -> code via VPS mailbox -> verify -> team_id -> api key -> TTS check -> bank row.
* `chr.py` — `ensure_chrome(port=9242)` CDP helper.
* `camb_shim.py` — OpenAI-compatible `/v1/audio/speech` shim over the key pool (round-robin, dead-key blacklist, 429 cooldown).
## Env
```
CAMB_VPS=root@your-vps # ssh host able to read the mailbox
CAMB_MAIL_READER=/root/camb_code.py
CAMB_KEYS=/opt/camb-shim/camb_keys.json
CAMB_SHIM_PORT=8822
```
## Dashboard
`dashboard.py` — stdlib-only web panel (no CDN, no deps), dark UI, auto-refresh 30s.
```bash
python3 dashboard.py --port 8823 --bank /opt/camb-dash/camb_bank.jsonl \
--stats /opt/camb-dash/camb_stats.json --shim http://127.0.0.1:8822 --refresh 900
```
| route | meaning |
|---|---|
| `GET /` | page: totals + per-account table |
| `GET /api/stats` | JSON snapshot (cached) |
| `GET /api/refresh` | force re-check of the pool |
| `GET /health` | liveness |
What it shows: records / unique accounts / keys / alive / dead, credits left and capacity,
spent, TTS phrases, dubs, USD value, shim health, and a table of accounts with the
last 6 chars of each key and its liveness.
Liveness is checked with `GET https://client.camb.ai/apis/list-voices` + `x-api-key`
(**200 = alive**, 401/403 = dead). It costs **zero credits** — do not use `tts-stream` for health.
Credits cannot be read per API key: `GET /payments/credits/team/<id>` answers `401 Unauthorized`
for an `x-api-key`/Bearer API key (it wants a user JWT). So the panel derives capacity as
`keys * 5000` and subtracts real TTS spends (`tts_credits` in the bank).
Unit file used in production:
```ini
[Unit]
Description=CAMB pool dashboard
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /opt/camb-dash/dashboard.py --port 8823 \
--bank /opt/camb-dash/camb_bank.jsonl --stats /opt/camb-dash/camb_stats.json \
--shim http://127.0.0.1:8822 --refresh 900
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
```
Caddy (behind an existing host, prefix mode — the page uses relative URLs on purpose):
```
redir /camb /camb/ 308
handle_path /camb/* {
reverse_proxy 127.0.0.1:8823
}
```
### Pitfalls
* `--port` overrides env. In the Windows/MSYS shell `VAR=val cmd &` silently loses the
variable, so the panel kept binding its default port; argv is the only reliable path.
* Port 8899 is taken by the ZTE proxy on the workstation — two processes ended up
`LISTEN` on it (SO_REUSEADDR) and every request died as "remote end closed connection".
Pick a port that is really free (`ss -lnt`), not just "looks free".
* `team_id` in the bank can be an int — `str()` it before `.strip()` or the refresh thread dies.