Zhipu AI (GLM) Chat
Call the Zhipu GLM series models via the OpenAI-compatible format.
Endpoint
POST $URL/v1/chat/completionsSupported Models
| Model | Positioning |
|---|---|
glm-5.2 | Zhipu's latest chat model |
Request Example
bash
curl $URL/v1/chat/completions \
-H "Authorization: Bearer $YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.2",
"messages": [
{"role": "user", "content": "Introduce the Forbidden City in Beijing"}
]
}'python
from openai import OpenAI
client = OpenAI(api_key="YOUR_API_KEY", base_url="$URL/v1")
resp = client.chat.completions.create(
model="glm-5.2",
messages=[{"role": "user", "content": "Introduce the Forbidden City in Beijing"}],
)
print(resp.choices[0].message.content)ts
import OpenAI from 'openai'
const client = new OpenAI({
apiKey: process.env.YOUR_API_KEY,
baseURL: '$URL/v1',
})
const resp = await client.chat.completions.create({
model: 'glm-5.2',
messages: [{ role: 'user', content: 'Introduce the Forbidden City in Beijing' }],
})
console.log(resp.choices[0].message.content)Notes
GLM models are fully compatible with the OpenAI format and use the standard messages structure. New Zhipu models will be added here as they become available.
