Instructions to use zai-org/GLM-5.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-5.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="zai-org/GLM-5.1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("zai-org/GLM-5.1") model = AutoModelForCausalLM.from_pretrained("zai-org/GLM-5.1", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use zai-org/GLM-5.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-5.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/GLM-5.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/zai-org/GLM-5.1
- SGLang
How to use zai-org/GLM-5.1 with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "zai-org/GLM-5.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/GLM-5.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "zai-org/GLM-5.1" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "zai-org/GLM-5.1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use zai-org/GLM-5.1 with Docker Model Runner:
docker model run hf.co/zai-org/GLM-5.1
Commit History
-
fix: guard against tools=None crash and string arguments in chat_template.jinja
Verified signature## Problem Two crashes can occur in `chat_template.jinja` when used with sglang or any OpenAI-compatible server: **1. `TypeError: 'NoneType' object is not iterable`** When a `role="tool"` message has non-string `content` (structured list), the template enters the `else` branch and executes `for tool in tools` — but `tools` is `None` when no tools were passed in the request. The top-level `{%- if tools -%}` guard at the top of the file does not cover this inner loop. Reproduces when replaying a tool-calling conversation history without re-passing the `tools` array, or when any client omits `tools` from the request. Related upstream issue: sgl-project/sglang#6702 **2. `AttributeError: 'str' object has no attribute 'items'`** In the `tool_calls` rendering block, `tc.arguments` is iterated with `.items()` assuming it is a dict. Several OpenAI-compatible clients and model outputs serialize arguments as a JSON string, causing a crash on this line. ## Fix - Wrap the inner `for tool i…ed810a1
-
update CyberGym score for Gemini 3.1 Pro and GPT-5.4
zRzRzRzRzRzRzRbef0214
-
Merge branch 'main' of hf.co:zai-org/GLM-5.1
zRzRzRzRzRzRzR0e12244 -
update
zRzRzRzRzRzRzR7015f16
-
Update .eval_results/swe_bench_pro.yaml (#10)
- Update .eval_results/swe_bench_pro.yaml (24746423c80e373b9611754163d868331411f764) Co-authored-by: Nathan Habib <SaylorTwift@users.noreply.huggingface.co>dd43008 -
update bench
zRzRzRzRzRzRzR146e9f2
-
add SWE-bench_Pro
zRzRzRzRzRzRzR278f446 -
GLM-5.1
zRzRzRzRzRzRzRbf3dec1 -
Update README.md
Verified signatureada0c51
-
Add files using upload-large-folder tool
Verified signature56bbdce -
Add files using upload-large-folder tool
Verified signature5b48738 -
Add files using upload-large-folder tool
Verified signature6f7b6cb -
Add files using upload-large-folder tool
Verified signature12ec8fb -
Add files using upload-large-folder tool
Verified signaturea1ec45e -
Add files using upload-large-folder tool
Verified signaturef5ed80e
-
initial commit
Verified signature385269b