GLM-5.2 has become one of the most searched models on the Ollama library, and for good reason. Built by Z.ai, it’s positioned as their flagship model for what they call “long-horizon tasks”: large, multi-step engineering work that unfolds over hours rather than minutes. In this tutorial, we’ll walk through what makes GLM-5.2 different, and how to actually run it using Ollama.
What is GLM-5.2?
GLM-5.2 is a mixture-of-experts language model with 756 billion total parameters, released under an MIT open-source license. Its standout feature is context length: it supports up to roughly 1 million tokens, designed to remain reliable across long, messy coding-agent sessions rather than simply accepting a larger input. The model also introduces adjustable “thinking effort” levels (High and Max), letting you trade off latency and compute cost against reasoning depth depending on how demanding the task is.
On coding benchmarks, GLM-5.2 shows a substantial jump over its predecessor GLM-5.1, and Z.ai’s own published results place it close to the top closed-source coding models while remaining the highest-ranked open-source model across several long-horizon benchmarks. Because of its size, GLM-5.2 is currently distributed on Ollama exclusively as a cloud-hosted model (tag: glm-5.2:cloud) rather than a local download: the full 756B-parameter model isn’t practical to run on consumer hardware, so Ollama routes inference to hosted infrastructure while keeping the same local CLI and API workflow you’d use for any other model.
Step 1: Install Ollama
If you haven’t already, download and install Ollama from ollama.com for your operating system (macOS, Windows, or Linux), then confirm it’s working:
ollama --version
Step 2: Sign in for Cloud Models
Cloud-tagged models like GLM-5.2 require an Ollama account to authenticate usage. Sign in from the CLI:
ollama signin
Step 3: Run GLM-5.2
Once signed in, start an interactive session directly from the terminal:
ollama run glm-5.2:cloud
This pulls the model reference and opens a prompt where you can start chatting immediately.
Step 4: Call It From Your Own Code
Ollama exposes a local API that proxies to the cloud model, so you can integrate GLM-5.2 into scripts and apps just like any other Ollama model.
Using cURL:
curl http://localhost:11434/api/generate -d '{"model": "glm-5.2:cloud", "prompt": "Explain the difference between a mutex and a semaphore."}'
Using Python (with the ollama package):
import ollama
response = ollama.chat(model="glm-5.2:cloud", messages=[
{"role": "user", "content": "Write a Python function to reverse a linked list."}
])
print(response["message"]["content"])
Using JavaScript:
import ollama from "ollama";
const response = await ollama.chat({
model: "glm-5.2:cloud",
messages: [{ role: "user", content: "Summarize this codebase's architecture." }],
});
console.log(response.message.content);
Step 5: Use It With Coding Agents
One of GLM-5.2’s biggest draws is agentic coding work, and Ollama makes it easy to plug the model into existing agent tooling using ollama launch. For example:
ollama launch claude --model glm-5.2:cloud
ollama launch codex --model glm-5.2:cloud
ollama launch opencode --model glm-5.2:cloud
These commands launch popular coding-agent front ends (Claude Code, Codex, OpenCode, and others) configured to use GLM-5.2 as the underlying model, letting you take advantage of its long context window for full project-level tasks.
Tips for Getting the Most Out of GLM-5.2
Since the model supports adjustable effort levels, it’s worth starting with the standard High setting for everyday coding and reasoning tasks, and reserving Max effort for genuinely hard problems where you’re willing to trade extra latency for better results. Given its 1M-token context, GLM-5.2 is also well suited to feeding in entire repositories or long design documents rather than chunking your context manually, which is where a lot of its long-horizon performance advantage comes from.