{"slug": "zcode-glm-5-4-wiring-a-third-party-api-into-an-agent-environment", "title": "ZCode + GLM-5.4: Wiring a Third-Party API Into an Agent Environment", "summary": "A developer wired Zhipu's GLM-5.4 into ZCode, Zhipu's agentic development environment, as a custom third-party provider by configuring four fields — Base URL, API format, API key, and model ID — and documented the four distinct failure modes each produces. In a small self-run comparison of three tasks (two rounds each, twelve requests), GLM-5.4 passed all six runs while GLM-5.3 failed both runs of a 120-character constrained-writing task, hitting the 1,200 max_tokens ceiling and returning empty content. The developer cautioned that the gap reflects behavior under a specific token ceiling rather than a general verdict, and that the tests involved no multi-file edits or tool calls.", "body_md": "I've been running GLM-5.4 inside ZCode through a custom provider rather than the official plan, and the setup turned out to be less about clicking the right buttons and more about understanding four fields and the four distinct failures they produce. This is the full walkthrough, including the measurements that changed how I use it.\n\nShort version: create a custom provider, fill Base URL, API format, API key, and model ID. Ten minutes of clicking. The rest of this post is about the parts that cost me time — and one measurement that made me revise my initial judgment of the model.\n\nZCode is Zhipu's Agentic Development Environment. It reads and writes files, runs terminal commands, drives a browser, and supports sub-agents and a goal mode. None of that requires Zhipu's own model — the client accepts any Anthropic- or OpenAI-compatible endpoint, which the docs call a third-party provider.\n\nSo the value proposition has two halves. Model choice decouples from the client: swap models server-side, change one field locally. And billing consolidates: one endpoint, one key, multiple vendors behind it.\n\nWhat it is not: a chat client. If your use case is asking questions in a browser tab, a desktop app is overkill. The payoff is on multi-step tasks where the model needs to touch files and run commands.\n\nReleased 2026-11-23. The headline change is Loop Transformer — a group of layers sharing weights and running repeatedly, adding depth without duplicating parameters. Zhipu's published version runs the 28 base layers twice, with the second pass continuing from the first's internal state. They describe validating up the ladder from 1B to 750B rather than training a fully-looped model from scratch.\n\nThe spec sheet, read from the crazyrouter catalog on 2026-11-25:\n\nThat last line is worth expanding. The launch material lists images and video as inputs, but that's Zhipu's own entry point. Through crazyrouter, `glm-5.4` is text-only — I sent an image and got \"I don't see any image\" back. For vision you need `glm-5v-turbo` or `glm-5.3-flash`. Same model name, different capability envelope depending on where you call it.\n\nThe launch material includes an internal 200-scenario comparison: GLM-5.4 versus GLM-5.3 at 51.1% win, 25.7% tie, 23.1% loss. Zhipu's own evaluation, no published tasks or rubric, so I can't rerun it.\n\nI wrote my own three tasks instead. Two rounds each, two models, twelve requests.\n\n**LRU cache class.** Pass criteria: contains a class, uses Map or Object, calls delete. glm-5.4 passed 2/2 at 139 and 131 tokens. glm-5.3 passed 2/2 at 674 and 632.\n\n**Paragraph to JSON.** Pass criteria: `JSON.parse` yields all three fields. glm-5.4 passed 2/2 at 52 and 35 tokens. glm-5.3 passed 2/2 at 717 and 712.\n\n**A 120-character explanation with three banned words.** Pass criteria: under 200 characters, no banned words. glm-5.4 passed 2/2 at 79 and 79. glm-5.3 passed 0/2 — both runs truncated.\n\nNobody got the answers wrong. The gap was in consumption and reliability. glm-5.4 stayed under a hundred output tokens across all three; glm-5.3 needed six to seven hundred. On wall time the LRU task ran 6.1s and 4.8s versus 17.6s and 17.6s; the JSON task 4.1s and 2.6s versus 26.5s and 26.8s.\n\nThe third task is the interesting one. glm-5.3 hit the 1,200 max_tokens ceiling both times and returned nothing. The usage numbers say why: a few dozen prompt tokens, completion pinned at 1,200, content empty. The budget went into reasoning and the actual paragraph never started.\n\nNow the caveats, which matter as much as the numbers. This shows glm-5.4 gets it right first try when acceptance criteria are tight. It does not show glm-5.4 is better on long tasks — none of these involved multi-file edits or tool calls. And glm-5.3's failure is a max_tokens artifact; an earlier run of the same script had it passing at 1,176 tokens. This is a difference *under a specific ceiling*, not a verdict.\n\nSince ZCode is an agent environment, a model that can't call tools is useless no matter how clean its answers are. I sent an OpenAI `tools` request asking for Hangzhou weather.\n\n**glm-5.4:** 15.5 seconds, called `get_weather`, args `{\"city\":\"杭州\"}`.\n\n**glm-5.3:** 3.1 seconds, called `get_weather`, args `{\"city\": \"杭州\"}`.\n\n**gpt-6.2-astra:** 3.3 seconds, called `get_weather`, args `{\"city\":\"杭州\"}`.\n\nAll three got the tool and argument right. But glm-5.4 took five times as long as the others — the opposite of its performance on the three short tasks.\n\nI chased it with a streaming request on a trivia question, recording time to first byte and the length of the `reasoning` field.\n\n**glm-5.4 run 1:** 3.5s to first byte, 4.2s total, 0 reasoning chars, 69 body chars.\n\n**glm-5.4 run 2:** 2.8s to first byte, 3.6s total, 0 reasoning chars, 81 body chars.\n\n**glm-5.3 run 1:** 1.9s to first byte, 9.9s total, 809 reasoning chars, 0 body chars.\n\n**glm-5.3 run 2:** 1.6s to first byte, 16.1s total, 504 reasoning chars, 93 body chars.\n\nA rerun matched. **glm-5.4 emitted zero reasoning characters every time; glm-5.3 always streamed several hundred characters of chain-of-thought first.**\n\nThat single fact explains both results. On a short task, silence is a feature — fewer tokens, less waiting. On a tool-call task needing multi-step judgment, silence means the model has to think without the scaffolding, and 15.5 seconds is the bill.\n\nThis is the part I'd carry into any agent setup. Benchmark scores from single-turn prompts will mislead you, because **the same model can go in opposite directions on short and long tasks**, and the pivot is whether it emits reasoning by default. ZCode exposes a reasoning level in the model menu; raising it amounts to forcing that step. Leave it default and your quick-prompt impression is probably wrong about the long task.\n\nThree things.\n\n**The client.** ZCode desktop for Windows, macOS, or Linux. No Node.js prerequisite — the runtime ships inside.\n\n**A key.** `sk-`-prefixed, created in the provider console. Not your login password.\n\n**A Base URL.** `https://api.crazyrouter.com/v1` here. Whether to include `/v1` varies by vendor; don't pattern-match.\n\n`sk-` string from the API Keys page`https://api.crazyrouter.com/v1`\n`glm-5.4`\nNo pre-validation happens client-side. A bad value surfaces on the first request, which is why the error table below earns its place.\n\nDownload for your OS, run the wizard, launch from the Start menu.\n\nTwo onboarding screens come before the workspace.\n\nThe first asks your primary work direction — twelve options from software development to legal work. It only tunes defaults; irrelevant to connecting your own endpoint. Click Skip, lower left.\n\nThe second is \"Welcome to ZCode,\" asking you to connect an account with a provider dropdown and a key field. That key belongs to the built-in service and is useless here. Click Skip for now.\n\nSkip both to reach the main interface. You lose account binding, not capability — file access and terminal calls are intact. What you don't have is a model channel, so the composer can't send anything until you add one.\n\nIn the browser this time.\n\nSign in to crazyrouter and open API Keys in the left column. The list breaks down by name, key, and status, with quota and available models on the same page.\n\nClick Create API Key. Three fields matter:\n\n`zcode` so you can identify it later. Cosmetic.\nThe key shows masked — leading characters, asterisks, trailing characters.\n\nClick copy for the real value, then paste into a scratch note and check both ends. Stray whitespace is the most common 401 cause, ahead of expired keys.\n\nFor the model ID, open the [catalog](https://crazyrouter.com/en/models) and type `glm`.\n\nCopy from the card. Don't change casing — `GLM-5.4` won't resolve, and the server won't guess for you.\n\nPer-model pricing sits on the [pricing page](https://crazyrouter.com/en/pricing?utm_source=devto&utm_medium=article&utm_campaign=offsite_article&utm_content=cr_b7d2d8d332bd_mid_text). Given glm-5.4 burned a fraction of glm-5.3's tokens in my tests, the invoice difference for identical work is easy to compute from that page.\n\nSettings → Model settings → Add provider. You get a card screen in two groups: built-in providers under Zhipu on top, and under \"Other\" below, Create custom provider is first.\n\nBuilt-in cards fix the address and protocol, so you supply only a key. Custom inverts that entirely. Not in the built-in list means this path.\n\nSomething recognizable — \"team gateway.\" Display only. But the model menu groups by provider once you have several, and duplicate model names across groups is normal, so clear naming prevents mis-clicks.\n\n`https://api.crazyrouter.com/v1`. Three traps:\n\n**Don't drop `/v1`.** I tried an address without it and got a bare 404 reading `Your base_url is missing /v1`. Unrelated to your key; add the path.\n\n**Don't append the endpoint yourself.** `/chat/completions` and `/messages` are chosen by the protocol dropdown. One layer from you plus one from the client equals another 404.\n\n**Address and protocol must match.** Anthropic Messages appends `/messages`; Chat Completions appends `/chat/completions`. Change one, re-check the other.\n\nThree options: `Chat Completions`, `Responses`, `Anthropic Messages`.\n\nI used `Anthropic Messages` — requests go to `/v1/messages`. `Chat Completions` also worked, `/v1/chat/completions` returning 200. Different payload shapes, same result: `content` array versus `choices`.\n\n`Responses` returns 400 for glm-5.4. Not your error — the model doesn't support that endpoint. Same address with `gpt-6.2-astra` returns 200. On a 400, check this dropdown first.\n\nPaste, then click the eye icon. Extra leading space or a missing tail becomes a 401.\n\nStored locally, never echoed in plaintext. Don't paste it into a chat for someone to inspect, and don't drop it in a group — that's handing over the keys.\n\nAdd model, enter `glm-5.4`. No auto-fetch for custom providers; this is manual, unlike built-in cards.\n\nWant glm-5.4 and glm-5.3-flash together? No second provider. Add another model under the same one — shared address and key, different ID.\n\nEasiest step to botch. Close without saving and everything above is wasted. Some versions give each provider a separate toggle that must also be on. Confirm both, then save.\n\nNew session, open the model menu, find the provider group, select your model. Ask it to repeat one sentence. One acceptance criterion: **a normal reply arrives.** If it does, all four fields are correct.\n\nSecurity note: the key lands in `~/.zcode/v2/provider_config.json` in plaintext. Don't commit that file.\n\n**Edit the config directly.** Everything in settings writes to `~/.zcode/v2/provider_config.json`. Custom providers go under `providerConfigRules.providerRules`, where `api.type` sets the protocol (`anthropic-messages`, `openai-chat-completions`, `openai-responses`) and `api.baseUrl` takes the full address. Good for bulk edits or replicating across machines.\n\nTwo gotchas. Broken JSON doesn't corrupt your file — the client neither modifies nor backs it up, just ignores your personal config temporarily while built-in providers keep working, and recovers when you fix it. And `manualProviderModelRules` demands every field; miss one and the entire personal config fails to load. For partial changes, use `providerModelRules`.\n\n**Enter from the login screen.** First launch or after sign-out lands on the login screen with browser authorization and use-API-key options. The latter goes straight to provider config — same panel, two fewer detours.\n\nOne thing ZCode doesn't offer: reusing a built-in provider's route via an environment variable override, a trick some clients allow so you inherit the built-in model naming. Here, anything outside the built-in list needs its own custom entry with address and model ID entered correctly.\n\n**401, invalid token** — pasted wrong, stray whitespace, or you used your login password. Re-copy and verify with the eye icon.\n\n**404, `Your base_url is missing /v1`** — add `/v1`, but don't also append `/messages`.\n\n**404, `model_not_found`** — misspelled ID or missing model permission on this key. Copy from the catalog.\n\n**400, `invalid_request_params`** — protocol set to `Responses`, unsupported by glm-5.4. Switch to `Anthropic Messages` or `Chat Completions`.\n\n**Image input fails** — model isn't multimodal. glm-5.4 is text-only; switch to `glm-5v-turbo`.\n\n**Empty or truncated reply** — max_tokens ceiling, reasoning ate the budget. Raise it or choose a shorter-output model.\n\nFive point at status codes. The last has no error — HTTP 200 — and only shows in usage: tiny prompt, completion at the ceiling, content empty.\n\nSplitting 401 from 404 is mechanical. 401 is identity: wrong key, missing key, malformed key. 404 is path and model: missing address segment, wrong protocol, nonexistent ID. No overlap, so no trial and error.\n\nWithin 404s, the message distinguishes them. Bad address says `base_url is missing /v1` or `Invalid endpoint path`. Bad model says `model_not_found` and points you to the catalog. The phrase tells you which field to edit.\n\nConnection failures and endless spinners are network. The HTTP proxy in ZCode settings isn't global, and model requests route through it — turn it off first.\n\nOne case lives outside the table: config is right, composer won't use the model. Check whether the session is pointed at the new group. Adding a provider doesn't move the active session.\n\nAfter switching, requests carry your key. Missing from the menu? Check the provider toggle, the model-row toggle, and whether the form saved. All fine and still missing — leave settings and re-enter to refresh.\n\nThe screenshot is glm-5.3; switching to glm-5.4 in the same provider means editing only the model ID field.\n\nThe durable lessons are few. Whether the Base URL carries `/v1` comes from vendor docs. Protocol and address travel together. The model ID gets copied, not typed. The key gets checked at both ends. Four fields, four error types, and status codes that point at the field.\n\nOn model choice: my tests favor glm-5.4 for short work, but the tool-call result argues against extrapolating. **Raise the reasoning level and re-measure before trusting a default-setting number on a long task.** That's the one thing I'd have gotten wrong if I'd stopped at the benchmark table.\n\nField names drift between versions. In 3.16.3 it's \"Base URL.\" Older builds may label it with a Chinese term for endpoint address, or split Anthropic and OpenAI into two inputs. Go by function, not by label.\n\nZCode official docs: zcode-ai.com/docs/configuration\n\nAPI: crazyrouter.com/en/models and crazyrouter.com/en/pricing", "url": "https://wpnews.pro/news/zcode-glm-5-4-wiring-a-third-party-api-into-an-agent-environment", "canonical_source": "https://dev.to/buluo/zcode-glm-54-wiring-a-third-party-api-into-an-agent-environment-52lb", "published_at": "2026-11-25 10:36:02+00:00", "updated_at": "2026-11-25 10:43:12.468581+00:00", "lang": "en", "topics": ["ai-agents", "large-language-models", "ai-tools", "developer-tools"], "entities": ["Zhipu", "GLM-5.4", "GLM-5.3", "ZCode", "crazyrouter", "glm-5v-turbo", "glm-5.3-flash"], "also_reported_by": [], "takeaway": "In a 12-request test, GLM-5.4 passed all six runs using under 100 output tokens per task, while GLM-5.3 burned 600-700 tokens per task and returned empty content on both runs of a 120-character task after hitting the 1,200 max_tokens ceiling.", "recommendation": {"advice": "Set tight acceptance criteria and watch completion-token usage against max_tokens; GLM-5.3 returned empty content twice when reasoning consumed the full 1,200-token budget.", "playbook": "evals-testing", "playbook_url": "https://wpnews.pro/playbooks/evals-testing"}, "alternates": {"html": "https://wpnews.pro/news/zcode-glm-5-4-wiring-a-third-party-api-into-an-agent-environment", "markdown": "https://wpnews.pro/news/zcode-glm-5-4-wiring-a-third-party-api-into-an-agent-environment.md", "text": "https://wpnews.pro/news/zcode-glm-5-4-wiring-a-third-party-api-into-an-agent-environment.txt", "jsonld": "https://wpnews.pro/news/zcode-glm-5-4-wiring-a-third-party-api-into-an-agent-environment.jsonld"}}