GLM52.pro

GLM 5.2 on HuggingFace

Download, run, and fine-tune GLM 5.2 through the official zai-org/GLM-5.2 repository.

Available Resources

ResourceRoleBest For
zai-org/GLM-5.2Official open weightsLocal serving, research, and fine-tuning
zai-org/GLM-5.2 recipesFramework guidesvLLM, SGLang, Transformers, KTransformers
OpenRouter z-ai/glm-5.2Hosted API routeOpenAI-compatible production API calls

Download with huggingface-hub

pip install huggingface-hub

from huggingface_hub import snapshot_download

snapshot_download(
    repo_id="zai-org/GLM-5.2",
    local_dir="./GLM-5.2",
    ignore_patterns=["*.msgpack", "*.h5"]
)

Run with Transformers

pip install transformers torch accelerate

from transformers import AutoTokenizer, AutoModelForCausalLM
import torch

model_id = "zai-org/GLM-5.2"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True
)

prompt = "Write a Python function to reverse a linked list"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

Serve with vLLM or SGLang

For API-style local deployment, prefer the supported serving frameworks instead of old GLM4 Ollama examples.

# vLLM
pip install vllm
vllm serve zai-org/GLM-5.2 --served-model-name glm-5.2

# SGLang
pip install sglang
python -m sglang.launch_server --model-path zai-org/GLM-5.2 --served-model-name glm-5.2

Context and API Note

GLM 5.2 is documented with a 1M-token context. For hosted access, use Z.ai direct APIs or OpenRouter model z-ai/glm-5.2.