# glm-5-3 (https://reapi.ai/docs/glm-5-3)

GLM 5.3 runs on `POST https://api.reapi.ai/v1/chat/completions` (OpenAI Chat Completions, primary) and `POST https://api.reapi.ai/v1/messages` (Anthropic Messages, for Anthropic SDKs and Claude Code) under the exact wire ID `glm-5.3`. Calls return a synchronous JSON payload or an SSE stream rather than an asynchronous task ID. [Current pricing and playground](/models/glm-5-3).

The request surface follows Z.AI's OpenAPI 3.0.1 Chat Completion schema for `glm-5.3`. Extra fields pass through untouched; upstream decides whether to apply, ignore, or reject them. The dated probe log below separates verified runtime behavior from vendor documentation.

## Quickstart

Create a key in [API keys](/settings/apikeys) and keep it on your server. The examples below disable SDK auto-retries so client retry policy stays explicit.

### cURL

    ```bash
    curl https://api.reapi.ai/v1/chat/completions \
      -H "Authorization: Bearer YOUR_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "model": "glm-5.3",
        "messages": [{"role": "user", "content": "Review a proposed checkout retry policy and identify duplicate-charge risks."}],
        "thinking": {"type": "enabled", "clear_thinking": false},
        "reasoning_effort": "low",
        "stream": true
      }'
    ```

### Python

    ```python
    from openai import OpenAI

    client = OpenAI(
        api_key="YOUR_API_KEY",
        base_url="https://api.reapi.ai/v1",
        max_retries=0,
    )
    response = client.chat.completions.create(
        model="glm-5.3",
        messages=[
            {
                "role": "user",
                "content": "Review a proposed checkout retry policy and identify duplicate-charge risks.",
            }
        ],
        extra_body={
            "thinking": {"type": "enabled", "clear_thinking": false},
            "reasoning_effort": "low",
        },
    )
    print(response.choices[0].message.content)
    assistant_message = response.choices[0].message.model_dump(exclude_none=True)
    ```

### Node.js

    ```js
    import OpenAI from 'openai';

    const client = new OpenAI({
      apiKey: 'YOUR_API_KEY',
      baseURL: 'https://api.reapi.ai/v1',
      maxRetries: 0,
    });
    const response = await client.chat.completions.create({
      model: 'glm-5.3',
      messages: [
        {
          role: 'user',
          content: 'Review a proposed checkout retry policy and identify duplicate-charge risks.',
        },
      ],
      thinking: { type: 'enabled', clear_thinking: false },
      reasoning_effort: 'low',
    });
    console.log(response.choices[0].message.content);
    const assistantMessage = response.choices[0].message;
    ```

### Go

    ```go
    package main

    import (
        "bytes"
        "io"
        "net/http"
        "os"
        "time"
    )

    func main() {
        body := []byte(`{"model":"glm-5.3","messages":[{"role":"user","content":"Review a proposed checkout retry policy and identify duplicate-charge risks."}],"thinking":{"type":"enabled","clear_thinking":false},"reasoning_effort":"low"}`)
        req, err := http.NewRequest("POST", "https://api.reapi.ai/v1/chat/completions", bytes.NewReader(body))
        if err != nil { panic(err) }
        req.Header.Set("Authorization", "Bearer YOUR_API_KEY")
        req.Header.Set("Content-Type", "application/json")
        client := &http.Client{Timeout: 120 * time.Second,
            CheckRedirect: func(req *http.Request, via []*http.Request) error { return http.ErrUseLastResponse }}
        res, err := client.Do(req)
        if err != nil { panic(err) }
        defer res.Body.Close()
        if _, err := io.Copy(os.Stdout, res.Body); err != nil { panic(err) }
        if res.StatusCode >= 400 { os.Exit(1) }
    }
    ```

## Endpoint

`POST https://api.reapi.ai/v1/chat/completions`

Send `Authorization: Bearer YOUR_API_KEY` and `Content-Type: application/json`. Responses use `application/json`, or `text/event-stream` when `stream: true`. Use the lowercase wire model ID `glm-5.3` (not the URL slug `glm-5-3`). There is no task-polling endpoint.

## Official input parameters

The table below lists the 16 top-level parameters in Z.AI's Chat Completion schema for `glm-5.3`, along with limits confirmed against the active gateway on December 5, 2026.

| Parameter          | Type      | Required / default                          | Meaning                                                                                                                                                |
| ------------------ | --------- | ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `model`            | string    | Required                                    | Model ID: `glm-5.3` (or `glm-5.3:<group>` for explicit group routing).                                                                                 |
| `messages`         | array     | Required                                    | Text-only conversation turns (`system`, `user`, `assistant`, `tool`). Multimodal `image_url` payloads return HTTP 400.                                 |
| `do_sample`        | boolean   | `true`                                      | Sampling toggle. Set `false` for greedy decoding (`temperature` and `top_p` do not apply).                                                             |
| `stream`           | boolean   | `false`                                     | Set `true` for SSE streaming ending with `data: [DONE]`. Recommended for long reasoning turns.                                                         |
| `thinking`         | object    | `{"type":"enabled","clear_thinking":false}` | Chain-of-thought settings. Z.AI documents GLM-5.3 as always-on reasoning; `clear_thinking: false` keeps reasoning intact across multi-turn tool calls. |
| `reasoning_effort` | string    | `"max"`                                     | Z.AI documents `"low"`, `"high"`, and `"max"` (upstream default `"max"`). Set `"low"` for fast, bounded turns.                                         |
| `temperature`      | number    | `1.0`                                       | Sampling randomness in `[0.0, 1.0]`. Tune either `temperature` or `top_p`, not both together.                                                          |
| `top_p`            | number    | `0.95`                                      | Nucleus sampling in `[0.01, 1.0]`. Tune either `temperature` or `top_p`, not both together.                                                            |
| `max_tokens`       | integer   | Omitted                                     | Maximum generated tokens (reasoning plus visible output). Active channel enforces `1`–`128000` (`128001` returns HTTP 400).                            |
| `tool_stream`      | boolean   | `false`                                     | Streams function-call argument deltas incrementally when paired with `stream: true`.                                                                   |
| `tools`            | array     | Omitted                                     | Up to 128 function tool definitions (`type: "function"`). Multi-turn tool loops are live-verified.                                                     |
| `tool_choice`      | string    | `"auto"`                                    | Tool selection mode when `tools` is passed.                                                                                                            |
| `stop`             | string\[] | Omitted                                     | Stop strings (up to 4 items). Verified truncating output cleanly on match.                                                                             |
| `response_format`  | object    | `{"type":"text"}`                           | Output format: `{"type":"text"}`, `{"type":"json_object"}`, or `{"type":"json_schema", ...}`.                                                          |
| `request_id`       | string    | Omitted                                     | Optional caller-supplied unique ID (`6`–`64` characters).                                                                                              |
| `user_id`          | string    | Omitted                                     | Optional end-user identifier (`6`–`128` characters). Avoid PII.                                                                                        |

Standard OpenAI Chat Completions options (`max_completion_tokens`, `n`, `seed`, `logprobs`, `top_logprobs`, `frequency_penalty`, `presence_penalty`) also pass through and were verified returning HTTP 200 on the active channel.

### Output cap and modality boundaries

* **Active channel cap (`128,000` tokens):** In December 5, 2026 live checks, `max_tokens: 128000` returned HTTP 200 while `128001` (and `131072`) returned HTTP 400 (`max_tokens_exceeded`). Both `max_tokens: 30` and `max_completion_tokens: 30` strictly stopped generation at 30 tokens (`finish_reason: "length"`).
* **Text-only input:** Sending `image_url` blocks returns HTTP 400. For screenshot, video, or document understanding, use [GLM 5.4](/docs/glm-5-4).
* **Context window:** **1,048,576 tokens (1M)** documented by Z.AI across input, reasoning history, tool payloads, and output. No full 1M-token stress test was run during integration checks.

## Multi-turn function calling and streaming tools

Pass `tools` and keep `stream: true` with `tool_stream: true` when building interactive coding agents. Execute tools in your application, append each `role: "tool"` result with its matching `tool_call_id`, and echo the returned assistant message unchanged:

```python
tools = [{
    "type": "function",
    "function": {
        "name": "get_deploy_status",
        "description": "Return the latest deployment status for a service.",
        "parameters": {
            "type": "object",
            "properties": {"service": {"type": "string"}},
            "required": ["service"],
        },
    },
}]

stream = client.chat.completions.create(
    model="glm-5.3",
    messages=[{"role": "user", "content": "Check deployment status for checkout-api."}],
    tools=tools,
    tool_choice="auto",
    stream=True,
    extra_body={
        "thinking": {"type": "enabled", "clear_thinking": False},
        "reasoning_effort": "low",
        "tool_stream": True,
    },
)

reasoning, content, calls = "", "", {}
for chunk in stream:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    thought = getattr(delta, "reasoning_content", None) or getattr(delta, "reasoning", None)
    if thought:
        reasoning += thought
    if delta.content:
        content += delta.content
    for tc in delta.tool_calls or []:
        slot = calls.setdefault(tc.index, {"id": "", "name": "", "arguments": ""})
        if tc.id:
            slot["id"] = tc.id
        if tc.function and tc.function.name:
            slot["name"] = tc.function.name
        if tc.function and tc.function.arguments:
            slot["arguments"] += tc.function.arguments
```

## Streaming

Set `stream: true` for SSE output. Read reasoning tokens from `delta.reasoning_content` or `delta.reasoning`, visible output from `delta.content`, and tool deltas from `delta.tool_calls`. reAPI requests `stream_options.include_usage: true` upstream so final token counts arrive before `data: [DONE]`. Treat any connection drop before `[DONE]` as incomplete.

## Capability observations — December 5, 2026

These live probes checked integration behavior through the active gateway; they are not an independent quality benchmark.

| Capability                                      | Observation                                                                                                                                                                                                                      |
| ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Non-stream text & billing receipt               | HTTP 200; returned answer, `usage`, and exact per-request billing receipt.                                                                                                                                                       |
| Streaming SSE                                   | HTTP 200 `text/event-stream`; streamed chunks, emitted trailing `usage`, and closed with `data: [DONE]`.                                                                                                                         |
| `reasoning_effort` levels                       | `low`, `high`, and `max` all returned HTTP 200. Other effort strings also returned HTTP 200 on the active channel, though Z.AI documents `low` / `high` / `max`.                                                                 |
| `thinking` options                              | `{"type":"enabled","clear_thinking":false}` and `clear_thinking: true` returned HTTP 200. Sending `{"type":"disabled"}` returned HTTP 200 on the current channel yet still produced reasoning tokens.                            |
| Output caps                                     | `max_tokens: 30` and `max_completion_tokens: 30` both capped strictly at 30 completion tokens (`finish_reason: "length"`). `128000` returned HTTP 200; `128001` returned HTTP 400 (`max_tokens_exceeded`).                       |
| Sampling, `stop`, `seed`, `logprobs`, penalties | `do_sample: false`, `temperature: 0.2`, `top_p: 0.8`, `seed: 42`, `frequency_penalty`, and `presence_penalty` returned HTTP 200. `stop: ["3"]` truncated cleanly at `"1 2 "`. `logprobs: true` returned token log probabilities. |
| Multiple choices (`n: 2`)                       | HTTP 200 with 2 choices returned (`choices.length === 2`).                                                                                                                                                                       |
| Structured output                               | Both `response_format: {"type":"json_object"}` and `json_schema` returned valid JSON. Keep application-side schema validation.                                                                                                   |
| Function tools & `tool_stream`                  | Two-turn function loop succeeded (`finish_reason: "tool_calls"` → final answer); `stream: true` + `tool_stream: true` streamed incremental argument chunks.                                                                      |
| Public `image_url`                              | Returned HTTP 400 confirming text-only input.                                                                                                                                                                                    |
| Anthropic Messages (`/v1/messages`)             | Non-stream JSON (`thinking` + `text` blocks), SSE streaming (`message_start` → `content_block_delta` → `message_stop`), and `tools` (`input_schema` → `tool_use`) all returned HTTP 200 with exact billing receipts.             |

## Anthropic Messages compatibility

If your client runs on an Anthropic SDK or Claude Code, call `POST https://api.reapi.ai/v1/messages` with `x-api-key` and `anthropic-version: 2023-06-01`:

```bash
curl https://api.reapi.ai/v1/messages \
  -H "x-api-key: YOUR_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.3",
    "max_tokens": 4096,
    "messages": [{"role": "user", "content": "Review this retry policy for idempotency bugs."}]
  }'
```

Use `/v1/chat/completions` when you need Z.AI-specific fields such as `thinking.clear_thinking`, `tool_stream`, or `do_sample`.

## Groups

Check [live group prices on the GLM 5.3 page](/models/glm-5-3#pricing). One reAPI key works across all available groups.

The bare `glm-5.3` ID routes to the default `glm` group. If additional groups appear in the price table, select one explicitly with `glm-5.3:<group>` as described in [LLM groups](/docs/api/llm-groups).

## Pricing and billing

Input tokens, output tokens (including thinking tokens), and cached input token reads are metered separately. See [current rates on the GLM 5.3 page](/models/glm-5-3); no numeric SKU prices are hardcoded here.

Settlement uses integer micro-USD: `microUSD = ceil(settled_USD_charge × 1,000,000)` and `credits = microUSD / 1,000`, where `1 credit = $0.001`.

reAPI forwards exactly one upstream request per accepted API call with no automatic retries and no server-side tool execution. Postpaid settlement requires valid delivery and usage evidence; upstream errors or interrupted streams settle with no charge.

## Output schema

A non-streaming response uses the Chat Completions envelope (illustrative token counts):

```json
{
  "id": "chatcmpl-req_0195f0d4b7a270008000123456789abc",
  "object": "chat.completion",
  "created": 1796445435,
  "model": "glm-5.3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Retrying on 5xx without an idempotency key can trigger duplicate charges...",
        "reasoning": "Check payment state transitions before recommending retry bounds..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 96,
    "completion_tokens": 74,
    "total_tokens": 170,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 22
    }
  }
}
```

## Errors

reAPI errors return `error.code`, `error.message`, `error.request_id`, and Chat-compatible `error.type`:

| HTTP / code                              | Meaning                                                                                                                            |
| ---------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
| 401 / `10001`–`10005`                    | Missing, invalid, or revoked API key.                                                                                              |
| 400 / `20001`, `20002`, `20003`, `20004` | Invalid JSON, missing fields, invalid parameter value (e.g. `max_tokens > 128000` or multimodal image parts), or unknown model ID. |
| 413 / `20008`                            | Request payload exceeds limit.                                                                                                     |
| 402 / `30001`                            | Insufficient balance.                                                                                                              |
| 429 / `50001`                            | Rate or in-flight concurrency limit reached.                                                                                       |
| 502–503 / `70001`                        | Upstream inference or pricing service unavailable.                                                                                 |

See the full [error-code catalog](/docs/api/errors).

## Tips

* Start with `reasoning_effort: "low"` and `stream: true` for routine reviews and tool loops; step up to `"high"` or `"max"` only when harder debugging justifies extra thinking tokens.
* Keep `max_tokens` at or below `128000`, and remember that thinking tokens share that budget with the visible answer.
* If your parser reads chain-of-thought traces on Chat Completions, check both `reasoning_content` and `reasoning` so it handles every gateway response shape cleanly.

## Related

Compare the [GLM 5.4 documentation](/docs/glm-5-4) (adds multimodal image/video/file inputs and Loop Transformer depth) and [GLM 5.2 documentation](/docs/glm-5-2), or visit the [GLM 5.3 model page](/models/glm-5-3) for live pricing and playground testing.

## Official references

* [Z.AI GLM-5.3 model guide](https://docs.z.ai/guides/llm/glm-5.3)
* [Z.AI Chat Completion OpenAPI reference](https://docs.z.ai/api-reference/llm/chat-completion)
* [Z.AI Thinking Mode guide](https://docs.z.ai/guides/capabilities/thinking-mode)
* [Z.AI pricing overview](https://docs.z.ai/guides/overview/pricing)