Most frontier models score well on HumanEval and then fall apart the moment you point them at a real GitHub issue — the kind that involves reading six files, reconciling conflicting constraints, and writing a patch that does not break the existing test suite. GLM 5.2 was built with exactly that gap in mind, and its coding numbers reflect it.
The Short Version
GLM 5.2 scores 62.1% on SWE-bench Pro, 78% on Terminal-Bench v2.1, and 90%+ on HumanEval. It runs at 158 tokens per second, accepts a 1-million-token context window, and is OpenAI-compatible — which means every major coding tool, from Continue.dev to Cursor, can plug into it with a two-line config change. If you want a single model to handle codebase-wide refactors, agentic shell tasks, and real-time autocomplete without switching tools, GLM 5.2 is worth a serious look.
Coding Benchmark Overview
The three benchmarks that matter most for real coding work are SWE-bench Pro (repository-level bug fixing), Terminal-Bench (agentic shell and CLI tasks), and HumanEval (function-level generation). Here is how GLM 5.2 sits across all three alongside its adjacent metrics.
| Benchmark | GLM 5.2 Score | What It Measures |
|---|---|---|
| SWE-bench Pro | 62.1% | Real GitHub issue resolution across hundreds of repos |
| FrontierSWE | 67.3% | Hard software engineering tasks, multi-file edits |
| Terminal-Bench v2.1 | 78% | Agentic terminal and shell coding tasks |
| HumanEval | 90%+ | Function-level code generation |
| GPQA Diamond | 89% | Graduate-level reasoning (proxy for hard debugging) |
SWE-bench Pro is the hardest practical test on this list. It pulls real issues from public GitHub repositories, gives the model the full repo, and checks whether the generated patch resolves the issue without breaking existing tests. A score of 62.1% puts GLM 5.2 in the top tier of currently available models.
Terminal-Bench v2.1 is newer and arguably more relevant to engineering workflows — it tests whether a model can operate autonomously in a shell: reading file trees, chaining commands, writing scripts, and recovering from errors. The 78% score is one of the highest published figures for this benchmark.
Why GLM 5.2 Works Well for Coding
Three architectural decisions explain GLM 5.2's coding performance.
1. 1-million-token context window. Most codebases can fit entirely inside a single prompt. A monorepo with 800,000 tokens of source code — roughly 600,000 lines — loads in one shot. There is no chunking, no retrieval-augmented plumbing, no risk of the model missing a relevant file because the retriever ranked it too low. You send the whole thing and ask your question.
2. 158 tokens per second. At that speed, a 4,000-token code completion comes back in about 25 seconds. A 20,000-token refactor of a large module takes roughly two minutes. Fast enough for interactive coding loops — not just batch runs overnight.
3. Native function calling. GLM 5.2 supports structured tool use, which is what coding agents actually need: read a file, run a test, write a patch, rerun the test. The function-calling interface follows the OpenAI schema exactly, so any agent framework that already handles GPT-4o tool calls will work without changes.
Best Prompt Patterns for Code Tasks
Prompt quality has an outsized effect on code output. The pattern that works reliably across all GLM 5.2 coding tasks is: role + task + output format + constraints.
Pattern 1: Bug Fix
You are a senior Python engineer. The function below raises a KeyError on empty input.
Fix it so it returns an empty list instead, and add a docstring.
Do not change the function signature.
[paste the function]The role primes the model's internal register. The explicit constraint ("do not change the function signature") prevents the model from rewriting the interface and breaking callers. Output format is implied by the task.
Pattern 2: Codebase-Wide Refactor
When you are working with a large codebase (GLM 5.2 fits up to 1M tokens), include the relevant files inline rather than asking the model to imagine them.
You are refactoring a Node.js Express API.
Here are the current route handlers, middleware, and types:
[paste all relevant files]
Task: Extract all database queries into a repository layer.
Output: New files for each repository class, plus a diff showing changes to the existing handlers.
Constraints: TypeScript only. Do not change the HTTP interface. Keep Jest test coverage.The model responds with a concrete directory structure, full file contents, and a summary of what changed — no hallucinated imports, because the actual source was in the prompt.
Pattern 3: Agentic Shell Task
For Terminal-Bench-style tasks where GLM 5.2 is driving a shell through function calls:
You have access to bash, read_file, and write_file tools.
Goal: Find all Python files in ./src that import requests, and replace the import with httpx.
Work step by step. Verify each change before moving to the next file.The "verify each change" constraint activates the model's self-checking behavior — it will run a grep after each substitution rather than batch-replacing blindly.
Pattern 4: Code Review
Review the following pull request diff for security issues, performance regressions, and violations of the style guide below.
Output: A numbered list of issues, each with severity (high/medium/low), file:line, and a suggested fix.
Style guide: [paste style guide]
Diff: [paste diff]The output-format specification ("numbered list... severity... file:line") keeps the review machine-parseable so it can feed into a CI comment bot.
IDE Integration: VS Code with Continue.dev
Continue.dev is the most popular open-source coding assistant extension for VS Code and JetBrains. It supports any OpenAI-compatible endpoint, so wiring it to GLM 5.2 takes about two minutes.
Step 1: Install Continue
Open VS Code, go to the Extensions panel, search for "Continue", and install the extension published by Continue.dev.
Step 2: Open the Config File
Press Cmd+Shift+P (or Ctrl+Shift+P on Windows/Linux) and run Continue: Open config.json. This opens ~/.continue/config.json.
Step 3: Add GLM 5.2 as a Provider
Replace the models array (or add to it) with:
{
"models": [
{
"title": "GLM 5.2",
"provider": "openai",
"model": "glm-5.2",
"apiKey": "YOUR_Z_AI_API_KEY",
"apiBase": "https://api.z.ai/v1"
}
]
}Save the file. Continue automatically reloads.
Step 4: Verify
Open any source file, select a block of code, and press Cmd+L to send it to the GLM 5.2 chat panel. You should see a response within a few seconds given the 158 t/s throughput.
Step 5: Set the Autocomplete Model (Optional)
For inline autocomplete, add a separate tabAutocompleteModel entry:
{
"tabAutocompleteModel": {
"title": "GLM 5.2 Autocomplete",
"provider": "openai",
"model": "glm-5.2",
"apiKey": "YOUR_Z_AI_API_KEY",
"apiBase": "https://api.z.ai/v1"
}
}At 158 t/s the autocomplete latency is low enough for real-time use in most files.
IDE Integration: Cursor
Cursor has a built-in custom model provider that works with any OpenAI-compatible endpoint.
Step 1: Open Cursor Settings
Click the gear icon in the bottom-left corner, or press Cmd+,. Navigate to Models.
Step 2: Add a Custom Provider
Scroll to the Custom Models section and click Add Model. Fill in:
- Model name:
glm-5.2 - API base URL:
https://api.z.ai/v1 - API key: your Z.ai API key
Click Save.
Step 3: Select GLM 5.2 as the Active Model
In the model dropdown at the top of the Cursor chat panel, select glm-5.2.
Step 4: Configure Long-Context Mode (Optional)
Cursor sends the entire file and relevant context automatically. Because GLM 5.2 accepts 1M tokens, you can increase Cursor's context budget in Settings > Context without hitting model limits. Set Max context tokens to the highest value Cursor exposes.
Step 5: Test with a Multi-File Task
Open the Cursor composer (Cmd+I), type a natural-language instruction like "Refactor the authentication module to use JWT refresh tokens", and let GLM 5.2 edit across files. The 1M context means Cursor can include far more project files in the prompt than it could with models that cap at 128K or 200K tokens.
OpenRouter Alternative
If you prefer not to manage a Z.ai API key, GLM 5.2 is also available on OpenRouter at model ID z-ai/glm-5.2. The base URL becomes https://openrouter.ai/api/v1. The config changes above apply identically — just swap the apiBase and apiKey fields.
Real-World Coding Use Cases
Whole-repo code review. Send an entire small-to-medium repository (under 800K tokens) in a single prompt and ask for a security audit, dependency analysis, or architecture critique. No retrieval step, no missed files.
Test generation. Paste a module and ask GLM 5.2 to generate comprehensive unit tests. The 90%+ HumanEval score means the generated test code is syntactically correct and logically grounded the vast majority of the time.
Automated issue triage. Feed a GitHub issue body plus the relevant files. Ask the model to (a) reproduce the problem in pseudocode, (b) identify the root cause, (c) propose a patch. The 62.1% SWE-bench Pro score reflects how often this workflow produces a working fix.
Shell scripting and DevOps. Terminal-Bench v2.1 at 78% covers bash scripting, Docker configuration, CI pipeline authoring, and command chaining. Ask GLM 5.2 to write a deployment script and it will produce something that actually runs — not a template with TODO placeholders.
Documentation generation. With the full source in context, GLM 5.2 can write accurate API documentation without hallucinating method signatures or parameter types. The output format prompt pattern (role + task + output format + constraints) is especially effective here: specify Markdown, JSDoc, or OpenAPI as the output format and the model will produce clean, parseable output.
Common Issues
| Issue | Likely Cause | Fix |
|---|---|---|
| Empty response in Continue | Wrong apiBase — trailing slash or typo | Set apiBase to https://api.z.ai/v1 exactly, no trailing slash |
| 401 Unauthorized | API key not set or expired | Regenerate the key at z.ai and update config |
| Slow autocomplete | Large file exceeding short-prompt budget | Reduce tabAutocompleteOptions.maxPromptTokens to 2048 in config.json |
| Model not found in Cursor | Wrong model name | Use glm-5.2 exactly (with hyphen, lowercase) |
| Context window error | Prompt exceeds 1M tokens | Split into multiple prompts or filter irrelevant files |
| Function calling not working | Agent framework expects strict mode | Add "strict": true to tool definitions; GLM 5.2 supports both modes |
Frequently Asked Questions
Does GLM 5.2 support image input for coding tasks? No. GLM 5.2 is text-only — it does not accept image or audio input. If you need to analyze a screenshot of an error or a UI mockup, you will need a multimodal model for that specific step.
What is the difference between GLM 5.2 and smaller GLM models for coding? GLM 5.2 is a 753B-parameter MoE model with 40B active parameters per forward pass. Smaller GLM variants trade benchmark performance for lower cost and latency. For codebase-level tasks (SWE-bench-style work), GLM 5.2's scores are substantially higher. For function-level completions where HumanEval performance is the main signal, a smaller model may be cost-effective enough.
How much does it cost to use GLM 5.2 for coding via the API? Input tokens are priced at $1.40 per million and output at $4.40 per million. Cache hits on repeated context cost $0.26 per million. For a typical coding session involving a 200K-token codebase prompt and 4K-token responses, the per-session cost is roughly $0.30. See the GLM 5.2 pricing breakdown for full per-use-case estimates.
Is GLM 5.2 open source? Can I self-host it? Yes. GLM 5.2 is released under the MIT license, and weights are available on Hugging Face at THUDM/GLM-5.2. Self-hosting a 753B MoE model requires significant GPU infrastructure. For most engineering teams, the hosted API at Z.ai is the practical path.
Does GLM 5.2 support streaming responses? Yes. The Z.ai endpoint supports Server-Sent Events streaming in the standard OpenAI format. Both Continue.dev and Cursor stream by default, which makes the 158 t/s throughput feel fast for interactive use — you start seeing output in about 1.54 seconds (TTFT) and tokens arrive continuously from there.
Can I use GLM 5.2 in a CI/CD pipeline?
Yes. Because it is OpenAI-compatible, any script that currently calls openai.ChatCompletion.create works against GLM 5.2 by changing base_url and api_key. Common CI use cases include automated PR review, test generation on new commits, and documentation linting.
What prompt length is practical for codebase-wide tasks? The 1M-token context window is the hard ceiling. In practice, a 500K-token prompt (roughly 375,000 lines of code) is a reasonable working size — it leaves room for the instruction, the model's output, and any conversation history. For most production services, that covers the entire source tree.
Bottom Line
GLM 5.2 occupies a specific and well-defined niche: it is the fastest frontier-class model (158 t/s) with a 1M-token context window and top-tier coding benchmark scores — 62.1% on SWE-bench Pro, 78% on Terminal-Bench v2.1. For engineering teams that need to run codebase-wide tasks, integrate a coding assistant into an existing OpenAI-compatible workflow, or build agentic pipelines that interact with a shell, those numbers translate directly into practical capability.
The IDE integrations above take about five minutes to configure. The prompt patterns work out of the box. If you have been using a model that tops out at 128K tokens or struggles with real GitHub issues, GLM 5.2 is a direct upgrade worth testing.
Try GLM 5.2 — no API key needed: glm5.app/chat.

