Z.AI shows how to build production-ready agent systems on GLM-5 with tool calling

Z.AI has shown how to turn GLM-5 into more than a chatbot: a production-ready agentic stack. The tutorial covers the basics: the SDK and OpenAI-compatible interface, streaming, thinking mode, tool calling, JSON output and a multi-turn loop with several tools. It also demonstrates how the model keeps context across turns and slots into existing Python code with almost no rewriting.

AI-processed from MarkTechPost; edited by Hamidun News
Z.AI shows how to build production-ready agent systems on GLM-5 with tool calling
Source: MarkTechPost. Collage: Hamidun News.
Listen to article

Z.AI has released an unusually useful technical walkthrough that presents GLM-5 not as yet another chat interface, but as a foundation for production-ready agent systems. The material moves step by step from a first request to the model to a full multi-step agent with tool calling, streaming output, thinking mode and multi-turn dialogue support. For developers this is an important signal: the bet is placed not only on answer quality, but on how mature the integration is in a real product stack.

The authors start by assembling a basic environment with zai-sdk, openai and rich, obtaining the API key from environment variables or through hidden terminal input, and spinning up a ZaiClient for the first model calls. Next comes a minimal chat completion scenario: GLM-5 answers a simple technical question, and then the same interface is used in streaming mode, where tokens arrive as they are generated. This is not a cosmetic feature. For interfaces, assistants and agent panels, streaming directly affects perceived speed, and therefore whether the model is suitable for working scenarios where the user does not want to wait for a long answer to finish in full.

The next block covers thinking mode and multi-turn context. In the example, thinking is explicitly enabled for GLM-5 with the parameter enabled, and the streamed response reads reasoning_content separately, followed by the model's final answer. The authors then build a chain of several messages: first they ask about the difference between list and tuple in Python, then clarify when NamedTuple is appropriate, and finally ask for a practical example with type hints.

The point of this section is not the questions themselves, but the demonstration that the model retains context between turns, while the developer can track the growth of the message history and token consumption. For agent systems this is a baseline requirement: without durable dialogue memory, complex chains quickly fall apart.

The most practical part begins where GLM-5 is connected to external functions. The tutorial describes two tools: a weather lookup and a calculator for safely evaluating expressions. The model receives a natural language request, decides on its own which tool to call and returns the arguments; local code executes the function, and the result is passed back into the model's context for the final answer.

Right after that, the tutorial shows structured output: GLM-5 is asked to extract financial data from a text and return clean JSON without explanations. This is very close to a typical production pattern, where a model must not only write well but also reliably produce machine-readable output for pipelines, CRMs, analytics or internal backend services.

The final technical block pulls everything together in a GLM5Agent class. It adds several tools at once: weather, calculator, current time and unit conversion. The agent works iteratively, calls the necessary functions on its own as it solves the task, and continues the loop until it gets a final answer or hits the step limit.

In a separate example, the authors compare how a tricky logic problem is handled with thinking mode on and off, measuring response time and the number of generated tokens. Finally, they show that GLM-5 can also be used through the standard OpenAI Python SDK: changing base_url is enough, and the familiar chat.completions interface keeps working.

According to the official Z.AI documentation, GLM-5 has a context of up to 200K tokens and a maximum of 128K output tokens, which makes this scenario especially interesting for long multi-step tasks.

What does this mean in practice? Z.AI is trying to lower the migration barrier for teams that already have OpenAI-compatible code but need a more pronounced agentic workflow: tools, JSON, streaming, dialogue memory and controllable execution loops. It also matters that the tutorial does not drift into abstractions and instead shows the minimal working setup around the model.

That said, there should be no illusions: the weather and calculator examples remain educational, and production will still require authorization, logging, retries, restrictions on tools and protection against unsafe calls. But as a map of GLM-5's capabilities, the material is useful: it shows that Z.AI's model is already being packaged not merely as an LLM for chat, but as a building block for applied AI agents.

Story
ZK
Zhemal Khamidun — CPO at Alpina Digital, product manager of AlpinaGPT. Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Hands-On AI Engineering · Hamidun Academy

Build & Ship Production AI Agents Without Boilerplate Code

Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.

Start 72h Free Trial →Vibe-Coding Intensive
What do you think?
Loading comments…