GLM 5.4 API Endpoints and Coding Plan Setup

Updated

Z.ai model guide and Coding Plan documentation · KingBench 4 cache observations

Use a GLM Coding Plan key with the client-specific endpoint to run GLM 5.4 today. Standalone metered API access is pending Z.ai’s security assessment.

Coding Plan access
$18 / $80 / $168 per month
Client protocols
3 Coding Plan base URLs
Off-peak credit rate
50% of standard

GLM Coding Plan access is live

The GLM 5.4 API is available today through Z.ai’s GLM Coding Plan endpoints. Lite costs $18, Pro $80 and Max $168 per month. The standalone pay-per-token endpoint is marked coming soon after Z.ai’s security assessment. Use a Coding Plan key for the client routes below and budget production metered traffic separately. Z.ai GLM-5.4 model guide.

GLM 5.4 API Coding Plan endpoints for Claude Code, Goose, Codex CLI, Cline and OpenCode, with credit rates
Use the base URL for your client’s protocol. Off-peak requests consume half the standard credits.

Generate the key under your personal or team Coding Plan and keep it in a secret store or local client credential store. Each device or runner needs access to the correct plan key. For plan allowances and the metered rollout status, see GLM 5.4 pricing.

Official Coding Plan endpoints and setup

Base URLs and model IDs by client
ClientProtocolBase URLModel
Claude Code / GooseAnthropic Messageshttps://api.z.ai/api/anthropicglm-5.4
OpenAI Codex CLIOpenAI Responseshttps://api.z.ai/api/v1glm-5.4
Cline / OpenCode / Roo CodeOpenAI-compatible Chat Completionshttps://api.z.ai/api/coding/paas/v4glm-5.4

Claude Code and Goose

With ZAI_API_KEY loaded in a Bash-compatible shell, launch Claude Code with the following settings. Claude Code uses the [1m] suffix to select the long context. In Goose, choose Anthropic Compatible, enter the same base URL and key, and set the model to glm-5.4. Z.ai Claude Code setup.

export ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
export ANTHROPIC_AUTH_TOKEN="$ZAI_API_KEY"
claude --model 'glm-5.4[1m]'

OpenAI Codex CLI

Create ~/.codex/models.json using Z.ai’s model catalog, then merge these settings into ~/.codex/config.toml. Export ZAI_API_KEY before launching Codex. Back up a config you already use and keep its other provider definitions. Z.ai Codex CLI setup and model catalog.

model = "glm-5.4"
model_provider = "ZAI"
model_catalog_json = "~/.codex/models.json"

[model_providers.ZAI] name = "ZAI" base_url = "https://api.z.ai/api/v1" env_key = "ZAI_API_KEY" wire_api = "responses"

Cline, OpenCode and Roo Code

In Cline or Roo Code, use these provider field values. In OpenCode, select Z.AI Coding Plan in opencode auth login, enter the plan key and select GLM 5.4 with /models. If setting up a custom compatible provider, use the same base URL.

Provider: OpenAI Compatible
Base URL: https://api.z.ai/api/coding/paas/v4
API key: your Coding Plan key
Model ID: glm-5.4

Send a short prompt first. Check the selected model and resource path in the client log with credentials redacted. Let the client append the resource path to the base URL. A wrong protocol can produce a route error even when the key is valid.

Keep the first smoke test small and disable tools if your client allows it. Once a plain response succeeds, run a harmless tool call in a disposable project. That isolates provider and authentication errors from tool permissions, prompt size and session state.

Credit burn and rolling rate limits

Use uncached, cached and output tokens as separate counters. Coding Plan credits are calculated as (uncached_input*4.6 + cached_input*1.1 + output*16)/10,000. The plan charges 50% fewer credits outside Monday–Friday, 14:00–18:00 UTC+8. Apply the discount after computing the weighted sum. Z.ai Coding Plan credit rules.

Personal Coding Plan credit allowances
PlanMonthlyRolling 5 hoursWeekly cap
Lite$182,00010,000
Pro$8012,00060,000
Max$16828,000140,000

Credits in the five-hour window refresh five hours after consumption. Weekly credits reset on their own seven-day schedule. A 50K-input turn with 40K cached tokens and 4K output uses 15.4 credits at the standard rate and 7.7 off-peak. Run your actual prompt and output sizes through the GLM 5.4 token counter, then estimate the heaviest five-hour block as well as the weekly total.

Handle peak-hour 429 and 529 responses

For 429, honor Retry-After when provided. If quota is exhausted, queue work until the applicable window refreshes. For a transient rate limit or 529 overloaded, reduce concurrency and use bounded exponential backoff with jitter. Cap the retry budget by elapsed time and stop retrying authentication or configuration failures. When streaming breaks after a tool action, check whether it completed before retrying the step.

Keep the prompt prefix stable

Put reusable instructions, tool definitions and repository context first. Append the task and changing data afterward. Keep tool schemas in a consistent order and reuse the session until compaction is necessary. The KingBench 4 reviewer observed roughly 90% cache hits in warm sessions and 98.4% across the suite. Measure the cache counters your client exposes before budgeting around those results. AICodeKing’s KingBench 4 test.

Use GLM 5.4 benchmarks to choose representative coding tests and GLM 5.4 open weights to track the separate self-hosting release.

Frequently asked questions

Is the standalone GLM 5.4 API live?

Z.ai lists the metered API as coming after a security assessment. Developers can already use GLM 5.4 through the Coding Plan routes.

Which GLM 5.4 endpoint does Codex CLI use?

Use https://api.z.ai/api/v1 with the Responses protocol, model glm-5.4 and a Coding Plan key.

What model ID should I use in Claude Code?

The served model ID is glm-5.4. In Claude Code, select glm-5.4[1m] for the long-context profile.

When does the 50% off-peak discount apply?

Model calls outside Monday–Friday 14:00–18:00 UTC+8 use half the standard credit rate. Both five-hour and weekly credit allowances apply.

How should I respond to 429 or 529 errors?

Honor Retry-After when available. Queue quota-limited work until credits refresh. Back off with jitter and lower concurrency for transient overload.