Skip to content
AnswerWell geo Documentation

Research · 7 min read · Answerwell

GLM Text Generation Models: Agent Workflows, Tool Calling, and Multimodal Flash

How to choose and run Z.ai GLM models on Workers AI—context limits, pricing, paid access, agents, and multimodal GLM-5.3 Flash.

This page summarises Cloudflare Workers AI documentation on the Z.ai (Zhipu AI) GLM family hosted at the edge: fast multilingual chat (@cf/zai-org/glm-4.7-flash), agentic coding tiers (@cf/zai-org/glm-5.2, @cf/zai-org/glm-5.3), and the multimodal MoE variant (@cf/zai-org/glm-5.3-flash). If you are picking a model ID, estimating cost, or wiring function calling into a Worker or agent, the tables and access rules below are the decision points.

Perplexity’s Agent API models list also groups GLM 5.3 and GLM 5.3 Flash as Z.AI reasoning models—a useful cross-check when you compare hosted GLM IDs across platforms, even though this page focuses on Cloudflare’s hosting and APIs.

GLM on Workers AI: which model ID fits your task

Section titled “GLM on Workers AI: which model ID fits your task”

Workers AI exposes four GLM text-generation models under the @cf/zai-org/ namespace. All support function calling on Cloudflare; newer GLM-5.x entries add stronger reasoning modes and much larger context windows, while GLM-4.7-Flash remains the economical choice for dialogue, multilingual apps, and lighter agent loops.

Model ID Best fit Context window (documented) Vision Billing
@cf/zai-org/glm-4.7-flash Low-latency chat, multilingual dialogue, multi-turn tools, long docs at modest cost 131,072 No Standard Workers AI pricing on model page
@cf/zai-org/glm-5.2 Agentic coding, long codebases, planning + tools 262,144 on Workers AI (model family up to 1,048,576) No Paid access required
@cf/zai-org/glm-5.3 Long-running, tool-driven dev workflows 1,048,576 No Same unit pricing as GLM-5.2; paid access
@cf/zai-org/glm-5.3-flash Coding/agents with multimodal inputs, large context at lower $/token than GLM-5.2 1,048,576 Yes Paid access

Cloudflare describes GLM-4.7-Flash as follows:

GLM-4.7-Flash is a fast and efficient multilingual text generation model with a 131,072 token context window. Optimized for dialogue, instruction-following, and multi-turn tool calling across 100+ languages.

— Cloudflare, glm-4.7-flash

For retrieval-style workloads (summarisation, RAG, AI Search generation), Cloudflare explicitly calls out GLM-4.7-Flash’s 131,072-token window as suitable for long-document summarisation and retrieval tasks in the new Workers AI models for text generation changelog.

GLM-5.2 and GLM-5.3: agentic coding vs single-turn chat

Section titled “GLM-5.2 and GLM-5.3: agentic coding vs single-turn chat”

GLM-5.2 was introduced as Z.ai’s flagship agentic coding model on Workers AI:

@cf/zai-org/glm-5.2 is a text generation model built for agentic coding workflows. With function calling and reasoning support, it can handle long codebases, multi-step planning, and tool-augmented agents.

— Cloudflare, Introducing GLM-5.2 on Workers AI

GLM-5.3 keeps the same base model as GLM-5.2 but improves post-training; Cloudflare positions it for long-running, tool-driven development rather than casual chat:

@cf/zai-org/glm-5.3 is now available on Workers AI. It is Z.ai’s flagship agentic coding model, built for long-running, tool-driven development workflows rather than single-turn chat.

— Cloudflare, Z.ai GLM-5.3 now available on Workers AI

On Workers AI, GLM-5.3 is priced identically to GLM-5.2 ($1.40 per M input tokens, $0.26 per M cached input tokens, $4.40 per M output tokens) while delivering higher scores on long-horizon benchmarks described in that same changelog—so for new agentic coding projects on a paid plan, GLM-5.3 is usually the default unless you depend on GLM-5.2-specific behaviour.

GLM-5.3 Flash: multimodal MoE at lower unit cost

Section titled “GLM-5.3 Flash: multimodal MoE at lower unit cost”

GLM-5.3 Flash is the first GLM-family model on Workers AI with multimodal inputs and a large MoE footprint:

@cf/zai-org/glm-5.3-flash is now available on Workers AI. It is the first natively multimodal model in the GLM-5 series, built on a Mixture-of-Experts architecture with 320B total parameters and 18B active per token.

— Cloudflare, Z.ai GLM-5.3 Flash now available on Workers AI

The glm-5.3-flash model page lists unit pricing at $0.15 per M input tokens, $0.50 per M output tokens, and $0.03 per M cached input tokens—substantially below GLM-5.2/5.3 on input/output—while still offering a 1,048,576-token context window, function calling, reasoning tiers (low / high / max), and vision.

Common conclusion: use GLM-4.7-Flash for cost-sensitive multilingual agents and chat; GLM-5.3 for heavy autonomous coding with megatoken context on a paid plan; GLM-5.3 Flash when you need vision or want GLM-5-class agent performance closer to GLM-5.2 pricing tiers.

GLM-5.2, GLM-5.3, and GLM-5.3 Flash share the same access gate on Workers AI:

This model is not available through standard Workers Free billing. To use it, upgrade to the Workers Paid plan or use prepaid AI Gateway credits.

— Cloudflare, glm-5.3

GLM-5.2’s Workers AI launch documents an important context caveat: the family supports up to 1,048,576 tokens, but Workers AI initially exposed 262,144 tokens for GLM-5.2 with a stated plan to increase it (Introducing GLM-5.2). GLM-5.3 and GLM-5.3 Flash model pages document the full 1,048,576-token window on Workers AI.

When using Pi AI with a Workers AI model id that Pi does not list, Cloudflare notes that missing metadata defaults to a 128,000-token context unless you pass real limits—for GLM-4.7-Flash you should set contextWindow: 131_072 explicitly (Pi AI configuration).

GLM-4.7-Flash remains eligible for certain machine payments (x402) flows via AI Gateway under the id z-ai/glm-4.7-flash (Machine Payments eligible models).

How to call GLM models: binding, REST, Gateway, and SDKs

Section titled “How to call GLM models: binding, REST, Gateway, and SDKs”

Cloudflare documents four invocation paths for GLM models (examples appear across GLM-5.x changelogs and GLM-4.7 announcements):

  • Workers AI binding (env.AI.run())
  • REST API at /run or OpenAI-compatible /v1/chat/completions
  • AI Gateway (routing, caching, rate limits, unified billing)
  • Framework adapters: Vercel AI SDK (workers-ai-provider), TanStack AI (@cloudflare/tanstack-ai), and Agents AI SDK (createAI from agents/models/ai-sdk)

The AI SDK integration guide states that every Workers AI model works with the same AI SDK patterns—streaming, tools, and structured output:

Every kind of model works with every AI SDK call:

— Cloudflare, AI SDK

A minimal pattern selects GLM-4.7-Flash and streams text from a Worker:

import { createAI } from "agents/models/ai-sdk";
import { streamText } from "ai";
const ai = createAI({ binding: env.AI });
const model = ai("@cf/zai-org/glm-4.7-flash");
const result = streamText({ model, prompt: "Write a haiku about Durable Objects." });
return result.toTextStreamResponse();

The same page shows multi-turn tool calling with generateText, custom tool() definitions, and stopWhen: isStepCount(3), plus structured output via Output.object() and a Zod schema—patterns that apply equally if you swap the model string for @cf/zai-org/glm-5.3 on a paid account.

For Cloudflare Agents over HTTP/SSE, HTTP and Server-Sent Events mirrors the AI SDK streamText + toTextStreamResponse() approach with @cf/zai-org/glm-4.7-flash.

The GLM-4.7-Flash launch changelog introduced @cloudflare/tanstack-ai, which wires Workers AI and AI Gateway into TanStack AI with four configuration modes (plain binding, plain REST, Gateway binding, Gateway REST) and helpers such as createWorkersAiChat for streaming chat with tool calling, structured output, and reasoning text streaming. Install with:

npm install @cloudflare/tanstack-ai @tanstack/ai

Gateway-side adapters in the same package can route third-party providers (OpenAI, Anthropic, Gemini, Grok, OpenRouter) through AI Gateway for caching and rate limiting—useful when a GLM model handles orchestration but other models handle specialised steps.

AI Search added @cf/zai-org/glm-5.3-flash for text generation in search instances, citing a 1,048,576-token context window on Workers AI. Configuration is instance-specific; the changelog points to Supported models documentation for AI Search (same post). Pair this with GLM-4.7-Flash when you need a lighter generator for retrieval-heavy pipelines (2026-04-09 models changelog).

Section titled “Model lifecycle: deprecations and recommended GLM replacements”

Cloudflare’s planned model deprecations (effective May 30, 2026 for listed ids) recommend @cf/zai-org/glm-4.7-flash as a fast multilingual replacement with multi-turn tool calling and coding capabilities, alongside Gemma and Kimi options for vision-heavy agent workloads. Many legacy Llama, Mistral, and smaller instruct models are sunset without a one-to-one GLM mapping—migrate agent code to explicit GLM-5.x ids when you need megatoken coding context and can meet paid-access requirements.

Common mistakes when using GLM on Workers AI

Section titled “Common mistakes when using GLM on Workers AI”
  • Assuming GLM-5.x runs on the free Workers AI quota — all three GLM-5 models require Workers Paid or prepaid AI Gateway credits (glm-5.2 model page).
  • Treating the 1M context as universally available on GLM-5.2 — verify the documented Workers AI window (262,144 at launch) vs GLM-5.3/5.3 Flash (1,048,576 on model pages).
  • Omitting client-side limits with Pi AI — always pass known contextWindow/maxTokens for @cf/zai-org/glm-4.7-flash (Pi AI).
  • Using GLM-5.3 Flash without a vision need — you may pay more in complexity than GLM-4.7-Flash for pure text chat; use Flash when multimodal input or GLM-5-class agent quality at Flash pricing is the goal (glm-5.3-flash).
  • Forgetting streaming — Cloudflare notes all Workers AI text generation models support streaming even when examples use non-streaming calls (choose a text generation model tutorial).
  1. Open the model page for your target id (for example glm-4.7-flash, glm-5.3, or glm-5.3-flash) and confirm context window, function calling, reasoning/vision flags, and unit pricing match what your Worker passes in requests.

  2. From a staging Worker, issue a minimal env.AI.run() or OpenAI-compatible /v1/chat/completions call with the exact model string (@cf/zai-org/glm-4.7-flash or your GLM-5.x id) and verify the response headers/body match the Workers AI changelog entry for that model.

  3. If you use GLM-5.x, confirm the account is on Workers Paid or AI Gateway prepaid credits before load testing, per the paid-access notice on glm-5.3.

  4. For agent features, run a two-turn tool-calling request using the patterns in AI SDK or stream via HTTP SSE and confirm tools execute and streaming completes.

  5. You can check automatically in Answerwell (our tool): https://answerwell.org/workspace

If something on this page does not match the linked Cloudflare or Perplexity documentation, email yimasynthetic@gmail.com with the page URL and the exact sentence you believe is wrong so it can be corrected or clarified.