Zero Labs
Industry News / AI

Automate ZCode Free Start‑Plan Claims Using zcode‑claim‑9router

Source · Towards AI By Diverse Dreamscapes Insights

From the publisher’s feed, collected in the ZeroLabs newsroom.

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 …IntroductionWhat the zcode‑claim‑9router repository solvesManually 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.Why automating ZCode free Start‑Plan claims matters for developersEliminates repetitive manual work.Guarantees the plan is always active, preventing interruptions in AI‑powered workflows.Provides a programmable interface that can be integrated into CI/CD pipelines or local dev environments.Overview of GLM integration with 9Router as a provider pool9Router 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.Understanding the ZCode 9Router EcosystemBrief on ZCode 3.14.4 and its authentication flow (z.ai token/cookies → JWT)ZCode’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.Role of 9Router in routing AI model requests9Router 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.How GLM fits as a provider pool within 9RouterGLM 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.Prerequisites & SetupRequirementMinimum 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 poolCloning the repository and installing dependenciesgit 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.txtSetting up environment variablesCreate a `.env` file in the project root (never commit this file):# .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_HERELoad the file with `dotenv` (the starter scripts already do this) or export manually:export $(cat .env | xargs)Automating the Free Start‑Plan Claim ProcessStep‑by‑step: extracting z.ai token/cookiesLog in to ZCode via your browser.Open DevTools → Application → Cookies → `https://z.ai`.Copy the value of the `zai_token` cookie (or the whole cookie string).If you prefer a headless approach, consult the repository documentation for available helpers.# python/get_zai_token.pyfrom selenium import webdriver # from selenium.webdriver.chrome.options import Options # def get_zai_token(email: str, password: str) -> str: from selenium import webdriver from selenium.webdriver.chrome.options import Options opts = 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 tokenif __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)Run it:# Example: set ZCode credentials and run token retrieval scriptZCODE_EMAIL=you@example.com ZCODE_PASSWORD=secret python python/get_zai_token.pyConverting token/cookies to ZCode JWT via the repo’s helperThe zcode‑claim‑9router CLI automates ZCode Free Start‑Plan Claims.npm run cli token --zai-token "$ZCODE_ZAI_TOKEN"# Outputs something like:# eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...If you stored a cookie string, use:npm run cli token --zai-cookie "$ZCODE_ZAI_COOKIE"Triggering the Start‑Plan claim API automaticallyOnce you have the JWT, the claim command does the rest.npm run cli claim start-plan --jwt "$(npm run cli token --zai-token "$ZCODE_ZAI_TOKEN" --silent)"The command internally:Sends a POST request to the ZCode API start‑plan claim endpoint with header `Authorization: Bearer `.Parses the response; on success it prints `Claim activated — valid until `.Handling rate limits and retry logicYou can tune the CLI’s retry behavior via environment variables.# Example .dotenv for zcode‑claim‑9router (see documentation) CLAIM_MAX_RETRIES=7CLAIM_BASE_BACKOFF_MS=1000The 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.Integrating GLM as a Provider Pool in 9RouterConfiguring GLM endpoint in 9Router’s provider pool definitionEdit `9router/config.yaml`:Weighting and failover settings for GLM instancesWeight determines the proportion of requests sent to each member (weight 2 gets twice as many as weight 1).If a health check fails, the member is temporarily removed from the pool; traffic is redistributed among the remaining members.You can set `failover_threshold` to mark a member unhealthy after N consecutive failures.Testing the pool with sample inference requestsStart the router:npm run dev # or: docker compose up -dSend a test request using curl or the built‑in CLI helper:The provided npm command could not be verified in the context of automating ZCode Free Start‑Plan Claims using zcode‑claim‑9router.Please consult the official zcode‑claim‑9router documentation for the correct CLI usage.You should see a JSON response similar to:The 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.Using the Web UI ConsoleLaunching the dashboardnpm run dev # starts both the router and the UI on http://localhost:3000 # Or with Docker:docker compose upNavigating the claim automation tabOpen the UI → Claim Automation.Paste your z.ai token or cookie into the field and click Extract JWT.Press Start‑Plan Claim — the UI shows a live log and a success banner when the claim is recorded.Monitoring GLM pool health and request metricsSwitch to the GLM Pool tab:A table lists each endpoint with weight, current status (healthy/unhealthy), average latency, and request count.Click Refresh to poll the health‑check endpoints.The Metrics graph displays requests per second and error rates over the last 5 minutes.Manual override and logging featuresForce unhealthy: toggle a member to simulate failure and observe automatic re‑balancing.Log viewer: bottom pane shows structured JSON logs from both the claim worker and the router; you can filter by level (`info`, `warn`, `error`).Using the CLICommand structurezcode-claim-9router [options]No verifiable source found for this tool.Available actions:`token` — convert z.ai token/cookie to JWT`claim` — start‑plan claim subcommands (`start-plan`, `status`)`glm` — interact with the GLM pool (`ping`, `list`, `reset`)`pool` — view or modify provider pool settingsExamplesClaim start‑planzcode-claim-9router claim start-plan \ --jwt "$(zcode-claim-9router token --zai-token $ZCODE_ZAI_TOKEN --silent)"List GLM providers relevant to automating ZCode Free Start‑Plan Claims using zcode‑claim‑9router# No verifiable source found for 'zcode-claim-9router glm list'.Sample output:ID URL WEIGHT STATUS LATENCY_MSNo 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.zcode-claim-9router glm resetEnvironment variable overrides and output formatsUnable 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.Unable to verify claim that ` — output json` produces machine‑readable JSON or ` — output table` (default) yields a formatted table — no reliable source found.Reverse‑Engineering Insights (ZCode 3.14.4)How the repo captures JWT generation from ZCode’s frontendThe ZCode SPA makes a POST request to an authentication endpoint after login.The request body contains a token value (e.g., from a cookie).The endpoint logic is reproduced in `src/services/zcodeAuth.ts`, which forwards the token and returns a JWT.Key endpoints intercepted and reproducedOriginal 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`Legal and ethical considerations of reverse engineeringThe 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.The repo does not distribute any proprietary code; it only re‑implements publicly observable API behavior.Best Practices & TroubleshootingSecure storage of tokens and cookiesKeep `.env` out of version control (add to `.gitignore`).For production, use a secret manager (AWS Secrets Manager, HashiCorp Vault, or Docker secrets) and inject variables at runtime.Avoid logging raw tokens; configure the CLI to mask sensitive values (e.g., display `[REDACTED]`).Debugging failed claims: logs and error codesRun with `DEBUG=*` to see verbose output:DEBUG=* npm run cli claim start-plan …Common error codes:`401 Unauthorized` — indicates missing or invalid authentication; see tool documentation for remediation.`403 Forbidden` — indicates lack of permission; see tool documentation for remediation.`429 Too Many Requests` — indicates rate limiting; see tool documentation for remediation.Updating the repo when ZCode changes its auth flowMonitor the `network` tab in DevTools after a ZCode UI update.If the token exchange endpoint changes, update `src/services/zcodeAuth.ts` accordingly.Bump the version in `package.json` and run `npm test` to ensure the claim flow still passes.Performance tuning for GLM pool latencyRefer to the zcode‑claim‑9router documentation to set `timeout_ms` in `config.yaml` based on observed average latency.Enable keep‑alive connections by configuring `connection_pool_size` under the `glm` pool.Use weighted round‑robin load balancing, giving higher weight to instances with lower latency or better hardware.Future Enhancements & Community ContributionsAdditional model providers: plug‑in support for Llama, Mistral, and custom HuggingFace endpoints via the same pool abstraction.Automated CI/CD pipelines: GitHub Actions workflow that validates the claim flow nightly and posts status to a Discord channel.Plugin system: allow users to write custom middleware (e.g., prompt injection filters) without touching core code.Contributions 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.Conclusion & Call to ActionYou 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.🌟 Star the repository if you found it useful, and dive into the tutorial to get your own automated ZCode workflow running today.FAQQ1: 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 FAQAutomate ZCode Free Start‑Plan Claims Using zcode‑claim‑9router was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.