Skip to content

Setup guide

Use GLM in OpenCode and OpenRouter, and track it

Two ways to run GLM-5.3 outside Z.ai's own tools: OpenCode with the Z.AI Coding Plan provider, or OpenRouter by the token. Setup, prices, and tracking.

· Facts checked October 3, 2026

  • OpenCode
  • OpenRouter

The short answer

In OpenCode, run /connect, search for Z.AI, and pick the Z.AI Coding Plan provider to use a GLM Coding Plan, or the plain Z.AI provider to pay per token. Through OpenRouter, GLM-5.3 and GLM-5.3-Flash are billed per token from many hosting providers, which makes spend easy to track but means the price and quantization depend on which provider serves the request.

At a glance

OpenCode/connect, then Z.AI Coding Plan for a plan key; keys are stored in OpenCode's local auth file.
OpenRouter idsz-ai/glm-5.3 and z-ai/glm-5.3-flash.
OpenRouter list priceGLM-5.3 $1.40 input and $4.40 output per million tokens; GLM-5.3-Flash $0.15 and $0.50.
ProvidersAbout 40 OpenRouter endpoints serve GLM-5.3, at different prices and quantizations.
BatchBatch variants on OpenRouter cost $0.45 and $2.00 for GLM-5.3.

OpenCode with Z.ai

OpenCode lists Z.ai as a built-in provider. Its docs and Z.ai's guide agree on the flow: connect the provider, paste the key, then choose the model.

  1. Run /connect in OpenCode, or opencode auth login in a terminal.
  2. Search for Z.AI and choose Z.AI Coding Plan if you subscribe to the GLM Coding Plan; choose Z.AI for a pay-as-you-go key.
  3. Paste the key from Z.ai's console.
  4. Run /models and pick GLM-5.3 or GLM-5.3-Flash.

OpenRouter: pay per token, many hosts

OpenRouter lists GLM-5.3 at Z.ai's own rates, $1.40 input and $4.40 output per million tokens, but routes requests across about 40 provider endpoints, some cheaper and some more expensive, and some running quantized weights. If consistent quality matters, use OpenRouter's provider routing options to pin a provider rather than letting the router pick on price.

OpenRouter also offers batch variants that cost far less, $0.45 input and $2.00 output for GLM-5.3, for work that can wait. Interactive coding agents need the regular variant.

Which route to pick

A Coding Plan suits steady daily use, because its credits cost less than the same tokens at API rates when you use most of them, as the GLM-5.3 cost guide shows. OpenRouter suits occasional use, mixing GLM with other models under one key, and teams that want spend reported per key. A Z.ai pay-as-you-go key sits between the two: Z.ai's own rates and caching, without OpenRouter's routing.

Tracking GLM usage

everyaitoken reads OpenCode's local database, so GLM sessions show up as tokens by model and project. For requests OpenCode sends straight to Z.ai, it shows the tokens but leaves them out of the dollar estimate with a note, because it holds no verified Z.ai price. For GLM through OpenRouter, it prices tokens from OpenRouter's model catalog and shows the spend OpenRouter reports for your key separately. The spend tracking guide covers the OpenRouter side.

Your own numbers

See what your AI coding really costs.

everyaitoken reads Claude Code, Codex, Cursor, OpenRouter, Gemini CLI, and OpenCode on your Mac. It shows limits with reset times, API-equivalent cost, and what caching saved or cost, in the menu bar and 17 widgets. $9 once.

FAQ

Questions

How do I add GLM to OpenCode?

Run /connect, search for Z.AI, choose Z.AI Coding Plan or Z.AI, paste your key, then pick the model with /models.

What is the OpenRouter model id for GLM-5.3?

z-ai/glm-5.3, and z-ai/glm-5.3-flash for the Flash model. Batch variants add :batch to the id.

Is GLM cheaper on OpenRouter than on Z.ai?

The listed price is the same as Z.ai's, but individual OpenRouter providers charge more or less and may serve quantized weights. Pin a provider if you want predictable price and quality.

Can I use the GLM Coding Plan through OpenRouter?

No. The plan works in Z.ai's supported coding tools with a Z.ai key. OpenRouter bills per token from its own credits.

Sources

Checked October 3, 2026. Plans and limits change; the linked pages are the authority.

  1. OpenCode docs: Providers
  2. Z.ai docs: OpenCode
  3. OpenRouter: GLM-5.3
  4. OpenRouter: GLM-5.3-Flash
  5. Z.ai docs: Pricing