qwenwork.ai: HTTP autoreg, API reverse notes, OpenAI-compatible shim

This commit is contained in:
2026-11-20 23:09:39 +02:00
commit 600e6e6e79
6 changed files with 770 additions and 0 deletions
+115
View File
@@ -0,0 +1,115 @@
# qwenwork.ai — API reference (reverse engineered)
Base: `https://qwenwork.ai`. Web client: Vite SPA at `/app`, manifest at `/app/.vite/manifest.json`
(843 entries, 414 JS chunks).
Auth: JWT in cookie `token` (403 chars) **and** `Authorization: Bearer <jwt>`.
Client headers that matter: `Origin`, `Referer: <base>/app/`, `X-Client-Source: web`,
`X-Mule-Language: en-US`.
## Registration / auth
| method | path | body / notes |
|---|---|---|
| POST | `/auth/email-codes` | `{email, purpose:"registration"|"login", captcha_token}` -> `{"code":"ok","data":{"retry_after_seconds":60}}`; 60 s throttle per address |
| POST | `/auth/local/register` | `{email, code, notification:false}` -> `{created:true,user:{id,email,nickname}}`; 409 `email-exists` if taken |
| POST | `/auth/local/login` | `{email, code}` -> same shape, sets cookie `token` |
| POST | `/auth/logout` | |
| GET | `/auth/google` | 302 -> accounts.google.com (`redirect_uri=/oauth-callback/google`, client_id `376662729962-6p89qbb0nd7e2vqr2da3jd7315mbnvdn`) |
| POST | `/auth/dingtalk/sso`, `/auth/dingtalk/consent` | CN/DingTalk entry |
| POST | `/auth/qr-login/transactions` | QR login (returns tx id, polls state) |
| POST | `/auth/oauth/login-request-url` | 400 without proper shape |
| POST | `/auth/oauth/accept-login`, `/accept-consent`, `/consent-check` | OAuth consent dance |
Captcha: Aliyun Captcha v3. `captcha_token` = **JSON string** of the 2captcha solution object
`{sceneId, certifyId, deviceToken, data}`. Object -> 400; `data` only -> 403 `human verification failed`.
## User
| method | path | notes |
|---|---|---|
| GET | `/user/info` | id, email, nickname, is_verified, language, page.month_requests (100000), month_traffic (5 GB) |
| GET | `/user/plans` | plan catalog: `subscription-sgp-free` ($0, daily_trial_credits 200, starter_credits 500), plus 2000 / pro 4000 / enterprise 3000-4500 |
| GET | `/user/v2/quota` | `{total, used, remaining, exceeded}` — `remaining` respects the hold |
| GET | `/user/v2/registration-benefits` | `starter_credit.eligible`, `daily_credit.eligible_now/eligible_from` |
| GET | `/user/wallets` | `active_wallets.total`, `daily_credits`, `longterm_credits`, `monthly_credits` |
| GET | `/user/billings?limit=N` | ledger: `{type: Bonus|Chat|Blocked, amount, detail:{title}, session_id, created_at}` |
| GET | `/user/billings/sessions/{sid}` | per-session charge, e.g. `0.0442` credit |
| GET | `/user/v2/personal-subscription-options` | `user_segment:NEW`, purchasable plans |
| GET | `/user/v2/personal-subscription-prices` | `free` purchasable:false, prices in cents |
| POST | `/user/v2/account-settings` | `{nickname, nation}` (onboarding, optional) |
| POST | `/user/v2/redeem` | `{code}` — redeem endpoint alive, no codes known |
| POST | `/user/v2/bind-account/create/aliyun` | header `Idempotency-Key: uuid4` -> `{success:true, uid, binding_state:"authorized"}` (no SMS) |
| GET | `/user/v2/bind-account/state/aliyun`, `/profile-status/aliyun`, `/accounts/aliyun` | binding state |
| GET | `/user/v2/account-context` | |
## Chat (the real inference path)
```
POST /api/chat-sessions
{
"agent_id": "7270e986-63e5-3c79-aeca-ffbd92bdef83",
"initial_prompt": {"text": "..."},
"mode": "flash" | "advanced" | "pro" | "qwen3.8-flash" | "glm-5.3" | ... ,
"extra_data": {"user_language": "en-US"},
"channel": "qwenwork_web"
}
-> 201 {"id": "<session>", "first_turn_id": "<turn>", ...}
-> 402 {"code":"INSUFFICIENT_RESOURCES","message":"Insufficient credits to start a session"}
```
```
GET /api/chat-sessions/{sid}/events?after={seq}
-> {"items":[
{"type":"method","method":"session","sub_type":"prompt"},
{"type":"method","method":"session","sub_type":"agent_thought_chunk",
"raw":{"params":{"update":{"content":{"text":"..."}},"_meta":{"seq_id":2}}}},
{"type":"method","method":"session","sub_type":"agent_message_chunk",
"raw":{"params":{"update":{"content":{"text":"PONG","type":"text"}}}}},
{"type":"result","sub_type":"prompt_response"}
]}
```
`after` is the last seen `raw.params._meta.seq_id`. Answer text lives only in
`agent_message_chunk`; `result/prompt_response` means finished but carries no text.
```
GET /api/chat-sessions/{sid} session object (end_time stays null over REST)
PATCH /api/chat-sessions/{sid} update (name/...); 422 on unknown fields
DELETE /api/chat-sessions/{sid} "Session deleted successfully"
GET /api/chat-sessions/recent?limit=N list
GET /api/chat-sessions/{sid}/children
GET /api/chat-modes, /api/desktop/chat-modes model catalog (11 entries)
GET /api/m/v1/chat-sessions/{sid}[/events] mobile mirror of the same API
POST /api/v1/sidebar/order sidebar reorder
PATCH /api/v1/chat-sessions/{id}/archive {archived_at}
```
WebSockets: `/api/chat-ws` (protobuf session management — the lifecycle that releases the credit
hold), `/api/notify-ws` (jsonrpc), `/ws`.
### Credit accounting
Every turn writes `Chat` (negative, e.g. `-0.0164`) plus, when the session is not finished by the
WS protocol, a single `Blocked` entry equal to **the entire remaining balance**:
```
Blocked -699.8323 Credits blocked
Chat -0.0164 "Reply With PROD OK" granularity:turn
```
`Blocked` is not released by `DELETE`/`PATCH`/`PUT`/`stop`/`cancel`. Accounts that took it stay at
`remaining 0, exceeded true` and return 402 on the next `POST /api/chat-sessions`.
## Business / enterprise extras
`/biz/signin` (separate login page), `/biz/enterprise/v1/plans`, `/biz/user/v1/skill-hub/*`
(connectors, expert kits, my-skills, installs), `/ecommerce/api/v1/*` (reference kits, dashboards,
brand profile), `/api/barn/v1/*`, `/api/v1/scheduler`, `/api/sessions/unread|remote-read|remote-unread`.
## Not working / closed
- `/api/v1/chat/completions` and every OpenAI-style path on the web host: 401 / 404.
- `qwenwork.cn`: `/auth/email-codes` -> 404 (email login disabled), CN entry via Alibaba fast-auth.
- Free plan (`subscription-sgp-free`) has `purchasable:false`; no REST route activates its credits.
- `/api/marketing/campaigns` -> 404.