[KongchangAI]
· 2 min read· 1,189 words

GLM 5.4 Lands on AI Gateway: A Coding Flagship Powered by Loop Transformer

GLM 5.4 Lands on AI Gateway: A Coding Flagship Powered by Loop Transformer

GLM 5.4 lands on AI Gateway, using Loop Transformer to deepen reasoning without adding parameters.

Z.ai's new flagship GLM 5.4 is now on AI Gateway, positioned for coding and agentic tasks and the first GLM built on Loop Transformer. The architecture runs shared layers twice in the forward pass to deepen reasoning without adding parameters, moving part of the reasoning into the second pass so chains of thought are shorter while internal computation stays intact. It adds image input for generalized coding (video/game code, 3D scenes, CAD-style design), keeps a 1M-token context with caching and sparse attention, and supports tool calling, structured outputs, and prompt caching. Access it as zai/glm-5.4 via AI SDK or coding agents with the Vercel CLI.

Z.ai's new-generation flagship model GLM 5.4 is now available on AI Gateway. The official positioning is clear: this is a model built for coding and agentic tasks, and it is the first GLM model based on the Loop Transformer architecture. For developers building AI programming workflows, the headline here isn't just "another new model" — it's how the architectural shift will affect real-world usage.

GLM 5.4 now on AI Gateway

Loop Transformer: Deeper Reasoning Without More Parameters

The core technical change in GLM 5.4 is the Loop Transformer architecture. It works by running a set of shared layers twice during the forward pass, deepening the model's reasoning process without increasing parameter count. In other words, the model doesn't get stronger by "bulking up" — it gets stronger by "thinking it through twice."

One detail Z.ai mentions is worth noting: part of the reasoning process moves from visible thinking tokens into the second forward pass, which shortens the chain of thought. For developers, this means the thinking content in outputs may be more concise, but the model's internal computation isn't cut back. The team is also upfront that on some hard tasks, the model will still reason for a long time before answering — so don't expect it to always respond instantly.

The value of this design approach lies in its cost structure. With parameter count unchanged, deployment and inference memory overhead are easier to control; meanwhile, the increase in reasoning depth maps directly to performance on complex coding tasks.

Background on Loop Transformer: The idea of repeating some Transformer layers during the forward pass so that weights get reused multiple times has gradually taken shape in research from 2024–2025. Representative approaches include recurrent layer designs like the Universal Transformer, as well as explorations of recurrent depth / looped transformers for large models. The core motivation is to trade more serial computation for stronger compositional reasoning under a fixed parameter budget. Unlike chain-of-thought, which requires explicitly outputting large numbers of intermediate tokens, loop depth happens in hidden-state space and produces no externally visible text, so it can complete equal or even deeper computation with fewer output tokens. The trade-off is more serial computation steps per request, which raises latency and inference compute usage — and explains why the model may still think for a long time on hard tasks. For developers, understanding this helps in judging when to use it and when to switch to a lighter model.

Visual Input and "Generalized Coding"

Unlike earlier GLM flagship models, GLM 5.4 now accepts image input. Z.ai pairs this capability with what it calls "generalized coding," covering scenarios such as:

  • Writing code to generate videos and games
  • Building 3D scenes
  • Doing CAD-style mechanical design

This goes well beyond the traditional notion of "writing business code." Visual input combined with code generation capability means the model can understand design drawings, UI sketches, or engineering blueprints and turn them into runnable code or 3D structures. For teams working in graphics, games, or industrial software, this is a new entry point worth experimenting with.

The boundaries of multimodal code generation: Having a model accept image input and output code essentially means chaining "perception" and "program synthesis" within a single context — the model first extracts structural information from the image (layout, dimensions, part relationships), then converts that information into an executable form, such as a Three.js scene graph, a parametric modeling script, or a CAD feature sequence. Compared with pure text input, these tasks demand higher spatial consistency and numerical precision, and the model is prone to dimension estimation errors or missing components. A safer practice is to first have it output an intermediate representation (such as a pseudocode structure, dimension table, or step list), verify it manually, and then generate the final code — especially in mechanical design scenarios involving tolerances and assembly relationships. These tasks also depend more on an executable feedback loop: feeding rendering results or geometry validation results back to the model often works better than one-shot generation.

Long Context and Engineering Interfaces

GLM 5.4 retains a 1M-token context window and uses caching and sparse attention to keep long-context requests efficient. This combination is critical for handling large codebases, long documents, or complex multi-turn agent sessions — a big window doesn't equal usability; whether you can maintain response speed and controllable cost under long context is the real dividing line.

At the interface level, the model supports tool calling, structured outputs, and prompt caching. These three are essentially standard equipment for today's agent workflows — none can be missing.

What sparse attention and prompt caching really mean: Standard attention's computational cost grows roughly quadratically with context length, so a million-token window would be prohibitively expensive with dense attention. Sparse attention reduces the cost to roughly linear by letting each token interact with only some tokens (such as a local window, blocks, or selected global tokens), at the price of a possible slight drop in precision for long-range dependencies. Prompt caching, meanwhile, saves the key-value cache of recurring prefixes (system prompts, tool definitions, large codebase indexes) so that subsequent requests can reuse them directly, billing and computing only the newly added portion. When the two are combined, the "time to first token" for long-context requests is mainly determined by the new content — but cache hits require a stable prefix. Putting variable content at the end of the prompt and fixed content up front is a common engineering technique for improving cache hit rates.

How to Get Started

On AI Gateway, the model name is zai/glm-5.4. Calling it with the AI SDK takes just one line:

import { streamText } from 'ai';

const result = streamText({
  model: 'zai/glm-5.4',
  prompt: 'Write a Three.js scene with a rotating, lit cube.',
});

To use it in coding agents like Claude Code, Codex, or Cursor, install the latest version of the Vercel CLI and run npx vercel ai-gateway setup, then select zai/glm-5.4 in your agent. An official model playground is also available for direct trials.

AI Gateway itself provides a unified API, tracks usage and cost, and lets you configure retries, failover, and performance optimizations to achieve higher uptime than any single provider. It also supports custom reports, Zero Data Retention, API key budgets, and routing rules. On billing, AI Gateway charges at the provider's list price as-is, with no markup and no platform fee on inference — BYOK (bring your own key) requests are covered the same way.

What to Watch

GLM 5.4's combination punch — Loop Transformer reasoning depth, image input, generalized coding scenarios, and 1M context — all points in the same direction: the model is evolving from a "code completion tool" into an engineering collaborator that can read images, build models, and run long tasks. But whether architectural innovation translates into stable real-world performance — especially reasoning latency on hard tasks and efficiency under long context — still needs to be validated by developers in their own scenarios. For teams already using AI Gateway to manage multi-model routing, adding a zai/glm-5.4 option costs almost nothing, while the value of experimentation is immediate.

#GLM 5.4#AI Gateway#Loop Transformer#Z.ai#coding model#1M token context#multimodal code generation
Share:

Related articles