Datacenter in the EU · EU jurisdiction · OpenAI-compatible API
GRUNDEN.AIbeta
GLM 5.2

Chat

General text-in / text-out. Streaming + tool-calling.

§ 01

Chat completions

POST /v1/chat/completions — OpenAI-compatible endpoint. Streaming via SSE is supported when stream: true.

bash
curl https://api.grunden.ai/v1/chat/completions \
  -H "Authorization: Bearer $GRUNDEN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.2",
    "messages": [{"role": "user", "content": "Hej!"}]
  }'
§ 02

Streaming

With stream: true, Server-Sent Events are returned in the OpenAI format — the same delta structure you're used to.

js
const stream = await client.chat.completions.create({
  model: "glm-5.2",
  stream: true,
  messages: [{ role: "user", content: "Skriv en haiku om regn" }],
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}
§ 03

Tool calling (function calling)

Define tools the model can call via tools. GLM 5.2 responds with tool_calls in the assistant message; you run the function yourself and send the result back with role: "tool".

json
{
  "model": "glm-5.2",
  "messages": [{"role": "user", "content": "Vad väger en blåval?"}],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "search_web",
        "parameters": {"type": "object", "properties": {"q": {"type": "string"}}}
      }
    }
  ]
}