Instructions to use zai-org/GLM-4.1V-9B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use zai-org/GLM-4.1V-9B-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="zai-org/GLM-4.1V-9B-Thinking") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("zai-org/GLM-4.1V-9B-Thinking") model = AutoModelForImageTextToText.from_pretrained("zai-org/GLM-4.1V-9B-Thinking") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use zai-org/GLM-4.1V-9B-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "zai-org/GLM-4.1V-9B-Thinking" # 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-4.1V-9B-Thinking", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/zai-org/GLM-4.1V-9B-Thinking
- SGLang
How to use zai-org/GLM-4.1V-9B-Thinking 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-4.1V-9B-Thinking" \ --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-4.1V-9B-Thinking", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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-4.1V-9B-Thinking" \ --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-4.1V-9B-Thinking", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use zai-org/GLM-4.1V-9B-Thinking with Docker Model Runner:
docker model run hf.co/zai-org/GLM-4.1V-9B-Thinking
Unable to get the model to process an image on my PC
I can run zai-org/GLM-4.1V-9B-Thinking behind vLLM and chat normally.
Vision also works when I pass an HTTPS image URL. But any attempt to use a local image (file://…) either (a) returns a 400 “must be a subpath of --allowed-local-media-path” even when it is, or (b) just hangs (no response body), with no useful error in the API logs. Earlier, base64 data URLs returned 500 with a Pillow decode error. The net effect: model can “see” web images, but cannot “see” local files.
Environment
OS: Windows 11 + WSL2 (Ubuntu)
Python: 3.12.9 (conda env)
vLLM: 0.10.1 (works great for other models)
Transformers: (whatever ships in this env; can provide exact version)
CUDA / Torch: CUDA 12.8 and 2.9.0.dev20250811+cu128
GPU(s): RTX 5090 and 3090
This is what I'm seeing no matter what I've tried, with trying to process an image:
(APIServer pid=1806) INFO: Started server process [1806]
(APIServer pid=1806) INFO: Waiting for application startup.
(APIServer pid=1806) INFO: Application startup complete.
(APIServer pid=1806) Using a slow image processor as use_fast is unset and a slow processor was saved with this model. use_fast=True will be the default behavior in v4.52, even if the model was saved with a slow processor. This will result in minor differences in outputs. You'll still be able to use a slow processor with use_fast=False.
(APIServer pid=1806) INFO 08-12 21:48:42 [chat_utils.py:470] Detected the chat template content format to be 'openai'. You can set --chat-template-content-format to override this.
Launch command:
nova@DESKTOP-L4B0FRV:~/ai_projects$ VLLM_ALLOW_LONG_MAX_MODEL_LEN=1
python3 -m vllm.entrypoints.openai.api_server
--model zai-org/GLM-4.1V-9B-Thinking
--served-model-name glm-4.1v-thinking
--trust-remote-code
--quantization bitsandbytes
--dtype auto
--host 172.25.46.120
--port 8000
--api-key vllm
--max-model-len 8192
--allowed-local-media-path /home/nova/ai_projects
I was able to get the model to run and process images using transformers just fine. For some reason no matter what I've tried, all I can get is normal text with vllm, reading images seems to be a problem.