> ## Documentation Index
> Fetch the complete documentation index at: https://mixroute.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GLM-5.4

> Call GLM-5.4 on MixRoute for long-context coding, reasoning, and image understanding.

GLM-5.4 is Z.ai's flagship reasoning model for complex coding and long-running agent workflows. Its Loop Transformer reuses layers across reasoning passes. Z.ai lists a 1M-token context window and up to 128K output tokens; the output is text.

The primary endpoint listed in the MixRoute Console is `POST /v1/chat/completions`. Set `MIXROUTE_API_KEY` before running the examples.

## Quick example

> [tab] cURL
>
> ```bash theme={null}
> curl https://api.mixroute.ai/v1/chat/completions \
>   -H "Authorization: Bearer $MIXROUTE_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "model": "glm-5.4",
>     "messages": [{"role": "user", "content": "Reply with the single word OK."}],
>     "max_tokens": 768
>   }'
> ```

> [tab] Python
>
> ```python theme={null}
> import os
>
> from openai import OpenAI
>
> client = OpenAI(
>     api_key=os.environ["MIXROUTE_API_KEY"],
>     base_url="https://api.mixroute.ai/v1",
> )
> response = client.chat.completions.create(
>     model="glm-5.4",
>     messages=[{"role": "user", "content": "Reply with the single word OK."}],
>     max_tokens=768,
> )
> print(response.choices[0].message.content)
> ```

## Chat Completions parameters

| Parameter | Type | Description |
| - | - | - |
| `model` | string | Required. Use `glm-5.4`. |
| `messages` | array | Required. Use a text string or an array of text and image content blocks. |
| `max_tokens` | integer | Maximum number of output tokens. Allow enough room for both reasoning and the final answer. |
| `stream` | boolean | Enable SSE with `true`. Read `choices[].delta.content` for text and `data: [DONE]` for the end of the stream. |
| `thinking.type` | string | Only `enabled` is supported by this model. |
| `reasoning_effort` | string | Reasoning depth: `low`, `high`, or `max`. |
| `tools` | array | Function definitions. Read `choices[].message.tool_calls` when the model requests a tool. |
| `response_format` | object | Use `{ "type": "json_object" }` for JSON output. |

In a non-streaming Chat Completions response, read `choices[0].message.content` for the final answer. The `reasoning_content` field, when returned, is separate from the final answer.

## Image input

Send `text` and `image_url` blocks in the same user message. Replace the example URL with an accessible HTTPS URL, or use a Base64 data URL. This request returns text, not a generated image.

```json theme={null}
{
  "model": "glm-5.4",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Describe the main elements in this image."},
        {"type": "image_url", "image_url": {"url": "https://example.com/image.png"}}
      ]
    }
  ],
  "max_tokens": 768
}
```

## Anthropic-compatible text

For text requests using an Anthropic-compatible client, `POST /v1/messages` also returned text in MixRoute tests. This is not the primary endpoint listed in the Console. The example below demonstrates text only; do not assume Chat Completions parameters or capabilities carry over.

```bash theme={null}
curl https://api.mixroute.ai/v1/messages \
  -H "x-api-key: $MIXROUTE_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5.4",
    "max_tokens": 768,
    "messages": [{"role": "user", "content": "Reply with the single word OK."}]
  }'
```

Read the `text` blocks in `content` for the final answer. Give the model enough output tokens to finish thinking and return text.

## API reference

* [Chat Completions](https://mixroute.ai/docs/api-reference/endpoint/chat-openai.md)
* [Messages](https://mixroute.ai/docs/api-reference/endpoint/messages.md)
* [Z.ai GLM-5.4 model guide](https://docs.z.ai/guides/llm/glm-5.4)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.