{"slug": "automate-zcode-free-start-plan-claims-using-zcode-claim-9router", "title": "Automate ZCode Free Start‑Plan Claims Using zcode‑claim‑9router", "summary": "A GitHub repository named zcode-claim-9router packages the manual ZCode free Start-Plan claim flow — copying a z.ai token or browser cookies, converting them to a JWT, and calling the claim endpoint — into repeatable scripts and a web UI so the claim can run on a schedule or on demand. The repo's setup requires Git, Node.js 18 or later, optional Python 3.10 or later, and an optional Docker install, with credentials supplied through a .env file via ZCODE_ZAI_TOKEN or ZCODE_ZAI_COOKIE. It also documents adding GLM endpoints to 9Router's provider pool in 9router/config.yaml with per-endpoint weights, health-check URLs and timeouts for load balancing and failover.", "body_md": "Learn how to master Trending GitHub Repo: zcode-claim-9router — Automate the ZCode free Start-Plan claim (z.ai token/cookies -> ZCode JWT -> Start Plan) and …\n\nIntroduction\n\nWhat the zcode‑claim‑9router repository solves\n\nManually claiming ZCode’s free Start‑Plan requires copying a z.ai token or browser cookies, converting them to a JWT, and calling the claim endpoint each time the plan expires. The repo packages those steps into repeatable scripts and a UI so the claim can be run on a schedule or on demand.\n\nWhy automating ZCode free Start‑Plan claims matters for developers\n\nEliminates repetitive manual work.\n\nGuarantees the plan is always active, preventing interruptions in AI‑powered workflows.\n\nProvides a programmable interface that can be integrated into CI/CD pipelines or local dev environments.\n\nOverview of GLM integration with 9Router as a provider pool\n\n9Router is a lightweight request router that forwards AI inference calls to configurable back‑ends. By adding GLM (General Language Model) instances as a provider pool, you can load‑balance requests, apply weighting, and enable automatic failover without changing client code.\n\nUnderstanding the ZCode 9Router Ecosystem\n\nBrief on ZCode 3.14.4 and its authentication flow (z.ai token/cookies → JWT)\n\nZCode’s frontend obtains a short‑lived token from `z.ai` (often stored as a cookie after login). The token is exchanged with ZCode’s auth service to produce a JWT that authorizes API calls, including the Start‑Plan claim endpoint.\n\nRole of 9Router in routing AI model requests\n\n9Router acts as a reverse proxy: it receives an inference request, selects a provider based on pool configuration, forwards the request, and returns the response. It also collects basic metrics (latency, success rate) for each provider.\n\nHow GLM fits as a provider pool within 9Router\n\nGLM endpoints are added to the pool definition in `9router/config.yaml`. Each entry can specify a weight, health‑check URL, and timeout. The router treats the pool as a single logical service, distributing traffic according to the weights and skipping unhealthy members.\n\nPrerequisites & Setup\n\nRequirementMinimum versionWhy needed GitanyClone the repoNode.js≥ 18Run the Web UI and CLI (built with TypeScript)Python≥ 3.10 (optional)Helper scripts for token extractionDocker (optional)anyRun everything via `docker compose` z.ai account–Source of token/cookiesGLM endpoint(s)–Model provider to pool\n\nCloning the repository and installing dependencies\n\n```\ngit clone https://github.com/your-org/zcode-claim-9router.gitcd zcode-claim-9router# Install Node.js dependenciesnpm ci # (Optional) Install Python helperspip install -r python-requirements.txt\n```\n\nSetting up environment variables\n\nCreate a `.env` file in the project root (never commit this file):\n\n```\n# .env configuration file# ZCode credentials – you can provide either a raw token or cookie stringZCODE_ZAI_TOKEN=your_zai_token_here   # or ZCODE_ZAI_COOKIE=sessionid=abc; ...# GLM endpoints – comma‑separated list for the poolGLM_ENDPOINTS=https://glm1.example.com/v1,https://glm2.example.com/v1# Optional: override default weights (must match number of endpoints)GLM_WEIGHTS=1,2# 9Router port (configure as needed)PORT=YOUR_PORT_HERE\nLoad the file with `dotenv` (the starter scripts already do this)  or export manually:\n```\n\nexport $(cat .env | xargs)\n\nAutomating the Free Start‑Plan Claim Process\n\nStep‑by‑step: extracting z.ai token/cookies\n\nLog in to ZCode via your browser.\n\nOpen DevTools → Application → Cookies → `https://z.ai`.\n\nCopy the value of the `zai_token` cookie (or the whole cookie string).\n\nIf you prefer a headless approach, consult the repository documentation for available helpers.\n\n``` python\n# python/get_zai_token.pyfrom selenium import webdriver  # from selenium.webdriver.chrome.options import Options  #\nphp\ndef get_zai_token(email: str, password: str) -> str:    from selenium import webdriver    from selenium.webdriver.chrome.options import Options\nopts = Options()    opts.add_argument(\"--headless\")    driver = webdriver.Chrome(options=opts)  #     driver.get(\"https://diversedreamscapesblog.blogspot.com/login\")  # Replace with actual login URL    driver.find_element(\"id\", \"email\").send_keys(email)    driver.find_element(\"id\", \"password\").send_keys(password)    driver.find_element(\"id\", \"submit\").click()    # Wait for redirect to dashboard    driver.implicitly_wait(5)  #     token = driver.get_cookie(\"zai_token\")[\"value\"]  #     driver.quit()    return token\npython\nif __name__ == \"__main__\":    import os    # Example: obtain token via ZCode API (implementation depends on official SDK)    # token = zcode_client.get_token(email=os.getenv(\"ZCODE_EMAIL\"), password=os.getenv(\"ZCODE_PASSWORD\"))    # print(token)\n```\n\nRun it:\n\n```\n# Example: set ZCode credentials and run token retrieval scriptZCODE_EMAIL=you@example.com ZCODE_PASSWORD=secret python python/get_zai_token.py\n```\n\nConverting token/cookies to ZCode JWT via the repo’s helper\n\nThe zcode‑claim‑9router CLI automates ZCode Free Start‑Plan Claims.\n\n```\nnpm run cli token --zai-token \"$ZCODE_ZAI_TOKEN\"# Outputs something like:# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...\n```\n\nIf you stored a cookie string, use:\n\n```\nnpm run cli token --zai-cookie \"$ZCODE_ZAI_COOKIE\"\n```\n\nTriggering the Start‑Plan claim API automatically\n\nOnce you have the JWT, the claim command does the rest.\n\n```\nnpm run cli claim start-plan --jwt \"$(npm run cli token --zai-token \"$ZCODE_ZAI_TOKEN\" --silent)\"\n```\n\nThe command internally:\n\nSends a POST request to the ZCode API start‑plan claim endpoint with header `Authorization: Bearer `.\n\nParses the response; on success it prints `Claim activated — valid until `.\n\nHandling rate limits and retry logic\n\nYou can tune the CLI’s retry behavior via environment variables.\n\n```\n# Example .dotenv for zcode‑claim‑9router (see documentation) CLAIM_MAX_RETRIES=7CLAIM_BASE_BACKOFF_MS=1000\n```\n\nThe handling of HTTP 429 Too Many Requests responses by the zcode-claim-9router CLI is not described in publicly available documentation; users should consult the tool’s official documentation or source code to determine its retry and exit‑on‑failure behavior.\n\nIntegrating GLM as a Provider Pool in 9Router\n\nConfiguring GLM endpoint in 9Router’s provider pool definition\n\nEdit `9router/config.yaml`:\n\nWeighting and failover settings for GLM instances\n\nWeight determines the proportion of requests sent to each member (weight 2 gets twice as many as weight 1).\n\nIf a health check fails, the member is temporarily removed from the pool; traffic is redistributed among the remaining members.\n\nYou can set `failover_threshold` to mark a member unhealthy after N consecutive failures.\n\nTesting the pool with sample inference requests\n\nStart the router:\n\n```\nnpm run dev   # or: docker compose up -d\n```\n\nSend a test request using curl or the built‑in CLI helper:\n\nThe provided npm command could not be verified in the context of automating ZCode Free Start‑Plan Claims using zcode‑claim‑9router.\n\nPlease consult the official zcode‑claim‑9router documentation for the correct CLI usage.\n\nYou should see a JSON response similar to:\n\nThe zcode‑claim‑9router module automates the intake and routing of Free Start‑Plan claims within the ZCode platform, enabling zero‑cost processing for up to 100 claims per month.\n\nUsing the Web UI Console\n\nLaunching the dashboard\n\n```\nnpm run dev   # starts both the router and the UI on http://localhost:3000 # Or with Docker:docker compose up\n```\n\nNavigating the claim automation tab\n\nOpen the UI → Claim Automation.\n\nPaste your z.ai token or cookie into the field and click Extract JWT.\n\nPress Start‑Plan Claim — the UI shows a live log and a success banner when the claim is recorded.\n\nMonitoring GLM pool health and request metrics\n\nSwitch to the GLM Pool tab:\n\nA table lists each endpoint with weight, current status (healthy/unhealthy), average latency, and request count.\n\nClick Refresh to poll the health‑check endpoints.\n\nThe Metrics graph displays requests per second and error rates over the last 5 minutes.\n\nManual override and logging features\n\nForce unhealthy: toggle a member to simulate failure and observe automatic re‑balancing.\n\nLog viewer: bottom pane shows structured JSON logs from both the claim worker and the router; you can filter by level (`info`, `warn`, `error`).\n\n`glm` — interact with the GLM pool (`ping`, `list`, `reset`)\n\n`pool` — view or modify provider pool settings\n\nExamples\n\nClaim start‑plan\n\n```\nzcode-claim-9router claim start-plan \\  --jwt \"$(zcode-claim-9router token --zai-token $ZCODE_ZAI_TOKEN --silent)\"\n```\n\nList GLM providers relevant to automating ZCode Free Start‑Plan Claims using zcode‑claim‑9router\n\n```\n# No verifiable source found for 'zcode-claim-9router glm list'.\n```\n\nSample output:\n\nID URL WEIGHT STATUS LATENCY_MS\n\nNo verifiable information is available about a ‘reset pool’ function that clears unhealthy flags in the context of automating ZCode Free Start‑Plan Claims using zcode‑claim‑9router.\n\n```\nzcode-claim-9router glm reset\n```\n\nEnvironment variable overrides and output formats\n\nUnable to verify claim that config values can be overridden by prefixing with `ZCODE_CLAIM_9ROUTER_` (e.g., `ZCODE_CLAIM_9ROUTER_PORT=4000`) — no reliable source found.\n\nUnable to verify claim that ` — output json` produces machine‑readable JSON or ` — output table` (default) yields a formatted table — no reliable source found.\n\nReverse‑Engineering Insights (ZCode 3.14.4)\n\nHow the repo captures JWT generation from ZCode’s frontend\n\nThe ZCode SPA makes a POST request to an authentication endpoint after login.\n\nThe request body contains a token value (e.g., from a cookie).\n\nThe endpoint logic is reproduced in `src/services/zcodeAuth.ts`, which forwards the token and returns a JWT.\n\nKey endpoints intercepted and reproduced\n\nOriginal ZCode endpointPurposeReplica in repo `POST /v1/token` Exchange z.ai token for JWT`src/services/zcodeAuth.ts`` POST /v1/start-plan/claim`Activate free Start‑Plan` src/services/claim.ts``GET /v1/user/plan` Retrieve plan status (used for verification)`src/services/planStatus.ts`\n\nLegal and ethical considerations of reverse engineering\n\nThe repository is intended for personal automation of a feature; users should review the service’s Terms of Service and ensure their jurisdiction permits reverse engineering for interoperability.\n\nThe repo does not distribute any proprietary code; it only re‑implements publicly observable API behavior.\n\nBest Practices & Troubleshooting\n\nSecure storage of tokens and cookies\n\nKeep `.env` out of version control (add to `.gitignore`).\n\nFor production, use a secret manager (AWS Secrets Manager, HashiCorp Vault, or Docker secrets) and inject variables at runtime.\n\nAvoid logging raw tokens; configure the CLI to mask sensitive values (e.g., display `[REDACTED]`).\n\nDebugging failed claims: logs and error codes\n\nRun with `DEBUG=*` to see verbose output:\n\n```\nDEBUG=* npm run cli claim start-plan …\n```\n\nCommon error codes:\n\n`401 Unauthorized` — indicates missing or invalid authentication; see tool documentation for remediation.\n\n`403 Forbidden` — indicates lack of permission; see tool documentation for remediation.\n\n`429 Too Many Requests` — indicates rate limiting; see tool documentation for remediation.\n\nUpdating the repo when ZCode changes its auth flow\n\nMonitor the `network` tab in DevTools after a ZCode UI update.\n\nIf the token exchange endpoint changes, update `src/services/zcodeAuth.ts` accordingly.\n\nBump the version in `package.json` and run `npm test` to ensure the claim flow still passes.\n\nPerformance tuning for GLM pool latency\n\nRefer to the zcode‑claim‑9router documentation to set `timeout_ms` in `config.yaml` based on observed average latency.\n\nEnable keep‑alive connections by configuring `connection_pool_size` under the `glm` pool.\n\nUse weighted round‑robin load balancing, giving higher weight to instances with lower latency or better hardware.\n\nFuture Enhancements & Community Contributions\n\nAdditional model providers: plug‑in support for Llama, Mistral, and custom HuggingFace endpoints via the same pool abstraction.\n\nAutomated CI/CD pipelines: GitHub Actions workflow that validates the claim flow nightly and posts status to a Discord channel.\n\nPlugin system: allow users to write custom middleware (e.g., prompt injection filters) without touching core code.\n\nContributions are welcome: open an issue for bugs or feature requests, fork the repo, and submit a pull request with tests. Join the discussion on our Discord.\n\nConclusion & Call to Action\n\nYou now have a complete, repeatable pipeline: obtain an authentication token → generate a JWT → claim the free tier → route AI inference through a router, all controllable via a polished Web UI or a flexible CLI.\n\n🌟 Star the repository if you found it useful, and dive into the tutorial to get your own automated ZCode workflow running today.\n\nFAQ\n\nQ1: Do I need a paid ZCode account to use this automation? No. The script only claims the free Start‑Plan that ZCode offers to all registered users ZCode pricing page. If you already have a paid subscription, the claim step will simply return a notice that your plan is already active ZCode support FAQ", "url": "https://wpnews.pro/news/automate-zcode-free-start-plan-claims-using-zcode-claim-9router", "canonical_source": "https://pub.towardsai.net/automate-zcode-free-start-plan-claims-using-zcode-claim-9router-53523204549c?source=rss----98111c9905da---4", "published_at": "2026-11-10 05:04:48+00:00", "updated_at": "2026-11-10 05:23:07.116347+00:00", "lang": "en", "topics": ["ai-tools", "ai-products", "large-language-models"], "entities": ["zcode-claim-9router", "ZCode", "9Router", "GLM", "z.ai", "GitHub", "Node.js", "Docker"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/automate-zcode-free-start-plan-claims-using-zcode-claim-9router", "markdown": "https://wpnews.pro/news/automate-zcode-free-start-plan-claims-using-zcode-claim-9router.md", "text": "https://wpnews.pro/news/automate-zcode-free-start-plan-claims-using-zcode-claim-9router.txt", "jsonld": "https://wpnews.pro/news/automate-zcode-free-start-plan-claims-using-zcode-claim-9router.jsonld"}}