⚡ New — Kimi K3 is live: bring your own Moonshot key →

← Blog

Zero to a GLM coding agent in one command

A coding agent on an open model, governed by BharatRouter — in one command. The installer putsOpenCode on your machine, writes the config, prompts for and verifies your keys, and runs a first query so the very first thing you see is the agent working.

Frontier coding quality at a fraction of the cost — GLM-4.7 on Baseten scored 99.9% to Opus 4.8's 100% on our coding benchmark, at ₹0.033 vs ₹0.39 per task, and faster (1.5s vs 2.9s).

Before you begin

Have two keys ready — the installer prompts for both and verifies them, so keep them on the clipboard:

  • A BharatRouter key (br-…) — sign up (new orgs get ₹100 credit), mint a key, and keep it handy. The installer asks for it first and smoke-tests it.
  • A GLM provider key for BYOK — from Baseten (the fast first-party GLM host — 1.5s in our benchmark), Zhipu (z.ai) (looks like <id>.<secret>) or OpenRouter. If glm-4.7 doesn't already route on your org, the installer detects it, prompts for this key, and saves it via /me/byok. (Already have GLM serving on your org? It skips this automatically.)

Install

macOS / Linux

curl -fsSL https://bharatrouter.com/install/glm.sh | bash

Windows (PowerShell)

irm https://bharatrouter.com/install/glm.ps1 | iex

The installer is idempotent and cross-platform — macOS (arm64/x64), Linux (x64/arm64) and Windows. It quietly handles the rough edges that usually eat an afternoon:

  • the broken opencode-ai npm postinstall — it installs the platform binary and shims it onto your PATH;
  • a non-writable or root-owned ~/.cache — it redirects XDG_CACHE_HOME;
  • sudo-less PATH on Linux — it falls back to ~/.local/bin;
  • first-time keys — a hidden prompt, stored 600 outside your shell rc, then smoke-tested;
  • GLM access — if glm-4.7 doesn't route on your org yet, it prompts for a Baseten, Zhipu or OpenRouter BYOK key and saves it via /me/byok.

Your first query, automatically

Once the keys check out, the installer immediately asks GLM“how much can a team save on coding-agent token costs versus a frontier model?” — so you watch the tool-loop run and the answer stream back, metered through your own gateway, before you type anything.

OpenCode running GLM-4.6 through BharatRouter, answering the cost-savings question — 4,261 tokens, $0.00 spent on BYOK
The first query, right after install — OpenCode driving GLM-4.6 through BharatRouter, metered on your key.

Then use it from anywhere

The installer leaves you an oc-glm launcher:

oc-glm                                            # interactive TUI
oc-glm run --model bharatrouter/glm-4.7 "<task>"  # one-shot

Swap the brain by changing one string — bharatrouter/glm-5.2(frontier-grade, 99.4%), bharatrouter/gpt-oss-120b (cheapest near-perfect, ₹0.014/task) or bharatrouter/glm-4.5-air (lighter) — on the same BharatRouter key. All benchmarked in GLM vs frontier.

Why route a coding agent through BharatRouter

  • Governance — per-org/team/model ₹ budgets and caps on a loop that burns tokens fast.
  • Metering — every turn logged with provider, model and token usage (streamed usage included).
  • Routing & failover — add fallback routes without touching the harness.
  • No lock-in — open MIT-licensed GLM models, one API, swap models freely.

Full recipe, installer scripts and config:View on GitHub → ·  Manual walkthrough: Run an open coding agent on GLM

Next in the series: which GLM host is fastest or cheapest · can open GLM match a frontier model? (we benchmarked it)

Go live in a few clicks. Install a governed GLM coding agent in one command — Codex- or Claude-Code-style, routed & metered through your own key.BharatRouter Code →
Was this helpful?
More notes, benchmarks, and practical guides.Back to the blog