glm-5.2: Chat completions
curl --request POST \
--url https://api.zerogpu.ai/v1/chat/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"model": "glm-5.2",
"messages": [
{
"role": "system",
"content": "You are a precise code-review assistant. Be brief."
},
{
"role": "user",
"content": "Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max."
}
]
}
'import requests
url = "https://api.zerogpu.ai/v1/chat/completions"
payload = {
"model": "glm-5.2",
"messages": [
{
"role": "system",
"content": "You are a precise code-review assistant. Be brief."
},
{
"role": "user",
"content": "Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max."
}
]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'glm-5.2',
messages: [
{role: 'system', content: 'You are a precise code-review assistant. Be brief.'},
{
role: 'user',
content: 'Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max.'
}
]
})
};
fetch('https://api.zerogpu.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));falsepackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zerogpu.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"glm-5.2\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a precise code-review assistant. Be brief.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://api.zerogpu.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"glm-5.2\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a precise code-review assistant. Be brief.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "id-1784840133815",
"object": "chat.completion",
"created": 1784840133,
"model": "glm-5.2",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "**1. The name confesses the crime** – \"And\" in a function name means it violates single responsibility: fetching, emailing, and logging are three separate concerns.\n\n**2. Split it** – Extract `getUserData()`, `sendEmail()`, and `logActivity()`, each independently testable and reusable.\n\n**3. Orchestrate at the edge** – If the sequence matters, compose them in a thin workflow function named for the *why* (e.g. `onUserSignup()`), not the *how*.",
"reasoning": "The name reveals the function does three unrelated things — fetch data, send email, log — a single-responsibility violation. Recommend splitting into three functions plus a thin orchestrator. Keep to 3 bullets.",
"tool_calls": []
}
}
],
"usage": {
"prompt_tokens": 58,
"completion_tokens": 151,
"total_tokens": 209
}
}By model
glm-5.2
Model details for glm-5.2. Reasoning, function calling, and batch tasks with a 1M-token context window.
POST
/
chat
/
completions
glm-5.2: Chat completions
curl --request POST \
--url https://api.zerogpu.ai/v1/chat/completions \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"model": "glm-5.2",
"messages": [
{
"role": "system",
"content": "You are a precise code-review assistant. Be brief."
},
{
"role": "user",
"content": "Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max."
}
]
}
'import requests
url = "https://api.zerogpu.ai/v1/chat/completions"
payload = {
"model": "glm-5.2",
"messages": [
{
"role": "system",
"content": "You are a precise code-review assistant. Be brief."
},
{
"role": "user",
"content": "Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max."
}
]
}
headers = {
"x-api-key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'x-api-key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'glm-5.2',
messages: [
{role: 'system', content: 'You are a precise code-review assistant. Be brief.'},
{
role: 'user',
content: 'Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max.'
}
]
})
};
fetch('https://api.zerogpu.ai/v1/chat/completions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));falsepackage main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.zerogpu.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"glm-5.2\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a precise code-review assistant. Be brief.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max.\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-api-key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}require 'uri'
require 'net/http'
url = URI("https://api.zerogpu.ai/v1/chat/completions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"glm-5.2\",\n \"messages\": [\n {\n \"role\": \"system\",\n \"content\": \"You are a precise code-review assistant. Be brief.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Review this function name: getUserDataAndSendEmailAndLog(). What does it tell you about the function, and how would you refactor it? 3 bullets max.\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "id-1784840133815",
"object": "chat.completion",
"created": 1784840133,
"model": "glm-5.2",
"choices": [
{
"index": 0,
"finish_reason": "stop",
"message": {
"role": "assistant",
"content": "**1. The name confesses the crime** – \"And\" in a function name means it violates single responsibility: fetching, emailing, and logging are three separate concerns.\n\n**2. Split it** – Extract `getUserData()`, `sendEmail()`, and `logActivity()`, each independently testable and reusable.\n\n**3. Orchestrate at the edge** – If the sequence matters, compose them in a thin workflow function named for the *why* (e.g. `onUserSignup()`), not the *how*.",
"reasoning": "The name reveals the function does three unrelated things — fetch data, send email, log — a single-responsibility violation. Recommend splitting into three functions plus a thin orchestrator. Keep to 3 bullets.",
"tool_calls": []
}
}
],
"usage": {
"prompt_tokens": 58,
"completion_tokens": 151,
"total_tokens": 209
}
}This model supports the Chat Completions API only. Send requests to
/v1/chat/completions — the Responses endpoint (/v1/responses) is not
available for this model.Z.ai’s GLM-5.2 is an open-weight Mixture-of-Experts flagship built for long-horizon tasks, with 753B total parameters activating 8 of 256 experts per token, served on ZeroGPU for general text generation. It sustains a solid 1,048,576-token (1M) context, reasons through a problem with flexible thinking effort before answering, and supports function calling and batch tasks. MIT-licensed with no usage restrictions. When the work spans entire repos, day-long agent sessions, or million-token documents, this is the model.References: Model docs • Terms • Privacy
Authorizations
Headers
Optional project identifier. Scopes the request to a specific project when provided.
Body
application/json
Model identifier (fixed for this playground). Use request examples to change use cases.
Allowed value:
"glm-5.2"Example:
"glm-5.2"
Maximum number of tokens to generate in the response.
Required range:
x >= 1Example:
800
Response
Success
The response is of type object.
⌘I

