How do I use GLM 5.1 in OpenCode?
z-ai/glm-5.1OpenCode reaches GLM 5.1 through the OpenAI-compatible chat address of UberLLM. In ~/.config/opencode/opencode.json, add a provider named uberllm that uses the @ai-sdk/openai-compatible package with baseURL set to https://api.uberllm.dev/v1, list z-ai/glm-5.1 under its models, put your UberLLM key in the UBERLLM_API_KEY environment variable, then pick uberllm/z-ai/glm-5.1 with /models. The limit numbers are the context size and the largest reply of GLM 5.1; OpenCode uses them to know when to compact a long session.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"uberllm": {
"npm": "@ai-sdk/openai-compatible",
"name": "UberLLM",
"options": {
"baseURL": "https://api.uberllm.dev/v1",
"apiKey": "{env:UBERLLM_API_KEY}"
},
"models": {
"z-ai/glm-5.1": {
"name": "GLM 5.1",
"limit": {
"context": 200000,
"output": 24000
}
}
}
}
},
"model": "uberllm/z-ai/glm-5.1"
}OpenCode calls: OpenAI chat completions https://api.uberllm.dev/v1/chat/completions · Full OpenCode guide
Replace ull_your_key with your UberLLM API key. One key works in every tool and for every model.
By API, GLM 5.1 answers on three addresses with the same UberLLM key and the model id z-ai/glm-5.1: OpenAI chat completions at https://api.uberllm.dev/v1/chat/completions, the OpenAI Responses API at https://api.uberllm.dev/v1/responses and the Anthropic Messages API at https://api.uberllm.dev/v1/messages.