v1

latestOpenAPI 3.1.02026-07-224941145.6 KB

Chat Completion

Creates a model response for the given chat conversation.

post/v1/chat/completions

Request body

model'glm-5.2' required

Model ID

reasoning_effort'max' | 'xhigh' | 'high' | 'medium' | 'low' | 'minimal' | 'none'

Controls how hard the model reasons; effective only when thinking is enabled. none/minimal skip thinking, low/medium map to high, xhigh maps to max.

max_tokensinteger

The maximum number of tokens to generate (up to 128K). Recommended >= 1024.

temperaturenumber

Sampling temperature. Higher values make output more random.

top_pnumber

Nucleus sampling threshold.

streamboolean

If true, stream partial message deltas using SSE.

toolsobject[]

A list of tools (functions or MCP) the model may call.

Example request

{
  "model": "glm-5.2",
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ],
  "temperature": 1
}

Response

Completion generated successfully

idstring required
objectstring required
createdinteger required

Unix timestamp

modelstring required

Example response

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "glm-5.2",
  "choices": [
    {
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      }
    }
  ]
}