# Z.ai API — Orthogonal API

> Pay-per-use API on Orthogonal. Each call is billed to your Orthogonal balance.
> Base API: `https://api.orthogonal.com/v1/run` · [llms.txt](https://orthogonal.com/llms.txt) · [browse all APIs](https://orthogonal.com/discover)

Z.ai’s GLM series large language models, including GLM-4.5 and GLM-4.6, focus on advanced reasoning, coding, and agentic capabilities through a unique Mixture-of-Experts (MoE) architecture that prioritizes model depth over width for better efficiency and reasoning.

**Verified:** no

## Access

**Run API:** `POST https://api.orthogonal.com/v1/run`
**Auth:** `Authorization: Bearer $ORTHOGONAL_API_KEY`
Get an API key at https://orthogonal.com/dashboard/settings/api-keys

Every call goes through the unified Run API: send the API `slug`, the endpoint `path`, and the `query`/`body` parameters. The response is `{ "success": true, "price": "<usd>", "data": { ... } }`.

## Endpoints

### Chat Completion

Create a chat completion model that generates AI replies for given conversation messages. It supports multimodal inputs (text, images, audio, video, file), offers configurable parameters (like temperature, max tokens, tool use), and supports both streaming and non-streaming output modes.

`POST /api/paas/v4/chat/completions`

**Estimated cost:** Dynamic — use `"dryRun": true` in the Run API request to check the exact cost before calling.

**Docs:** https://docs.z.ai/api-reference/llm/chat-completion

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `model` | string | Yes | The model code to be called. GLM-4.6 are the latest flagship model series, foundational models specifically designed for agent applications. |
| `messages` | object[] | Yes | The current conversation message list as the model’s prompt input, provided in JSON array format, e.g.,`{“role”: “user”, “content”: “Hello”}`. Possible message types include system messages, user messages, assistant messages, and tool messages. Note: The input must not consist of system messages or assistant messages only. |
| `request_id` | string | No | Passed by the user side, needs to be unique; used to distinguish each request. If not provided by the user side, the platform will generate one by default. |
| `do_sample` | boolean | No | When do_sample is true, sampling strategy is enabled; when do_sample is false, sampling strategy parameters such as temperature and top_p will not take effect. |
| `stream` | boolean | No | This parameter should be set to false or omitted when using synchronous call. It indicates that the model returns all content at once after generating all content. Default value is false. If set to true, the model will return the generated content in chunks via standard Event Stream. When the Event Stream ends, a `data: [DONE]` message will be returned. |
| `thinking` | object | No | Only supported by GLM-4.5 series and higher models. This parameter is used to control whether the model enable the chain of thought. |
| `temperature` | number | No | Sampling temperature, controls the randomness of the output, must be a positive number within the range: `[0.0, 1.0]`. The GLM-4.6 series default value is `1.0`, GLM-4.5 series default value is `0.6`, GLM-4-32B-0414-128K default value is `0.75`. |
| `top_p` | number | No | Another method of temperature sampling, value range is: `[0.01, 1.0]`. The GLM-4.6, GLM-4.5 series default value is `0.95`, GLM-4-32B-0414-128K default value is `0.9`. |
| `max_tokens` | integer | No | The maximum number of tokens for model output, the GLM-4.6 series supports 128K maximum output, the GLM-4.5 series supports 96K maximum output, the GLM-4.5v series supports 16K maximum output, GLM-4-32B-0414-128K supports 16K maximum output. |
| `tool_stream` | boolean | No | Whether to enable streaming response for Function Calls. Default value is false. Only supported by GLM-4.6. Refer the [Stream Tool Call](/guides/tools/stream-tool) |
| `tools` | object[] | No | A list of tools the model may call. Currently, only functions are supported as a tool. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported. |
| `tool_choice` | string | No | Controls how the model selects a tool. Used to control how the model selects which function to call. This is only applicable when the tool type is function. The default value is auto, and only auto is supported. |
| `stop` | string | No | Stop word list. Generation stops when the model encounters any specified string. Currently, only one stop word is supported, in the format ["stop_word1"]. |
| `response_format` | object | No | Specifies the response format of the model. Defaults to text. Supports two formats:{ "type": "text" } plain text mode, returns natural language text, { "type": "json_object" } JSON mode, returns valid JSON data. When using JSON mode, it’s recommended to clearly request JSON output in the prompt. |
| `user_id` | string | No | Unique ID for the end user, 6–128 characters. Avoid using sensitive information. |

```bash
curl -X POST 'https://api.orthogonal.com/v1/run' \
  -H 'Authorization: Bearer $ORTHOGONAL_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"api":"zai","path":"/api/paas/v4/chat/completions","body":{"model":"<string>","messages":"<object>","request_id":"<string>","do_sample":"<boolean>","stream":"<boolean>","thinking":"<object>","temperature":"<number>","top_p":"<number>","max_tokens":"<integer>","tool_stream":"<boolean>","tools":"<object>","tool_choice":"<string>","stop":"<string>","response_format":"<object>","user_id":"<string>"}}'
```

---

Full details and an interactive quickstart: https://orthogonal.com/discover/zai
