---
title: "POST /paas/v4/chat/completions"
method: POST
path: "/paas/v4/chat/completions"
---

# POST /paas/v4/chat/completions

`POST /paas/v4/chat/completions`

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.

## Headers

- `Accept-Language` 'en-US,en' — Config desired response language for HTTP requests.

## Request body

- union
  - ChatCompletionTextRequest
    - `model` 'glm-5.3' | 'glm-5.2' | 'glm-5.1' | 'glm-5-turbo' | 'glm-5' | 'glm-4.7' | 'glm-4.7-flash' | 'glm-4.7-flashx' | 'glm-4.6' | 'glm-4.5' | 'glm-4.5-air' | 'glm-4.5-x' | 'glm-4.5-airx' | 'glm-4.5-flash' | 'glm-4-32b-0414-128k', required — The model code to be called. GLM-5.3, GLM-5.2, GLM-5.1, GLM-5-Turbo are the latest flagship model series, foundational models specifically designed for agent applications.
    - `messages` union[], required — 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.
      - union
        - object
          - `role` 'user', required — Role of the message author
          - `content` string, required — Text message content
        - object
          - `role` 'system', required — Role of the message author
          - `content` string, required — Message text content
        - object — Can include tool calls
          - `role` 'assistant', required — Role of the message author
          - `content` string — Text message content
          - `tool_calls` object[] — Tool call messages generated by the model. When this field is provided, content is usually empty.
            - `id` string, required — Tool call ID
            - `type` 'function' | 'web_search' | 'retrieval', required — Tool type, supports web_search, retrieval, function
            - `function` object — Function call information, not empty when type is function
              - …
        - object
          - `role` 'tool', required — Role of the message author
          - `content` string, required — Message text content
          - `tool_call_id` string, required — Indicates the tool call ID corresponding to this message
    - `do_sample` boolean — 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. Default value is `true`.
    - `stream` boolean — 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` ChatThinking — Only supported by GLM-4.5 series and higher models. This parameter is used to control whether the model enable the chain of thought.
      - `type` 'enabled' | 'disabled' — Whether to enable the chain of thought(`GLM-5.3` can only be enabled, and the thinking depth is controlled by `reasoning_effort`; for other models, when enabled, GLM-5.2 GLM-5.1 GLM-5 GLM-5-Turbo GLM-5V-Turbo GLM-4.6 GLM-4.5 and others will automatically determine whether to think, while GLM-4.7 and GLM-4.5V will think compulsorily), default: enabled
      - `clear_thinking` boolean — Default value is True. Controls whether to clear `reasoning_content` from previous conversation turns. View more in [Thinking Mode](/guides/capabilities/thinking-mode). - `true` (default): For this request, the system ignores/removes `reasoning_content` from prior turns, and only keeps non-reasoning context (e.g., user/assistant visible text, tool calls, and tool results). This is recommended for general chat or lightweight tasks to reduce context length and cost. - `false`: Retains `reasoning_content` from prior turns and includes it in the context sent to the model. To enable Preserved Thinking, you must forward the full, unmodified, and correctly ordered historical `reasoning_content` in `messages`. Missing, truncated, rewritten, or reordered blocks may degrade performance or prevent the feature from taking effect. - Notes: This parameter only affects cross-turn historical thinking blocks; it does not change whether the model generates/returns thinking in the current turn.
    - `reasoning_effort` 'max' | 'xhigh' | 'high' | 'medium' | 'low' | 'minimal' | 'none' — Controls the model's reasoning effort level, takes effect when `thinking` is enabled. Default is `max`, supported by `GLM-5.2` and above. For the `GLM-5.3` model, only the `low` / `high` / `max` levels are supported. For the `GLM-5.2` model, for compatibility with other protocols, passing `none` or `minimal` will cause the model to skip thinking; `low` and `medium` will be mapped to `high`; `xhigh` will be mapped to `max`.
    - `temperature` number, float — Sampling temperature, controls the randomness of the output, must be a positive number within the range: `[0.0, 1.0]`. The GLM-5.3, GLM-5.2, GLM-5.1, GLM-5, GLM-4.7, 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, float — Another method of temperature sampling, value range is: `[0.01, 1.0]`. The GLM-5.3, GLM-5.2, GLM-5.1, GLM-5, GLM-4.7, 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 — The maximum number of tokens for model output, the GLM-5.3, GLM-5.2, GLM-5.1, GLM-5, GLM-4.7, GLM-4.6 series supports 128K maximum output, the GLM-4.5 series supports 96K maximum output, the GLM-4.6v series supports 32K maximum output, the GLM-4.5v series supports 16K maximum output, GLM-4-32B-0414-128K supports 16K maximum output.
    - `tool_stream` boolean — Whether to enable streaming response for Function Calls. Default value is false. Only supported by the GLM-5.3, GLM-5.2, GLM-5.1, GLM-5, GLM-5-Turbo, GLM-4.7, and GLM-4.6 series. Refer to the [Stream Tool Call](/guides/tools/stream-tool)
    - `tools` union[] — 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.
      - union
        - FunctionToolSchema
          - `type` 'function', required
          - `function` FunctionObject, required
            - `name` string, required — The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
            - `description` string, required — A description of what the function does, used by the model to choose when and how to call the function.
            - `parameters` FunctionParameters, required — Parameters defined using JSON Schema. Must pass a JSON Schema object to accurately define accepted parameters. Omit if no parameters are needed when calling the function.
        - RetrievalToolSchema
          - `type` 'retrieval', required
          - `retrieval` RetrievalObject, required
            - `knowledge_id` string, required — Knowledge base ID, created or obtained from the platform
            - `prompt_template` string — Prompt template for requesting the model, a custom request template containing placeholders `{{ knowledge }}` and `{{ question }}`. Default template: Search for the answer to the question `{{question}}` in the document `{{ knowledge }}`. If an answer is found, respond only using statements from the document; if no answer is found, use your own knowledge to answer and inform the user that the information is not from the document. Do not repeat the question, start the answer directly.
        - WebSearchToolSchema
          - `type` 'web_search', required
          - `web_search` WebSearchObject, required
            - `enable` boolean — Whether to enable search functionality. Default is `false`. Set to true to `enable`.
            - `search_engine` 'search_pro_jina', required — Type of search engine. Default is `search_pro_jina`. Supports: `search_pro_jina`.
            - `search_query` string — Force trigger a search
            - `count` integer — Number of returned results Range: `1-50`, max `50` results per search Default is `10` Supported engines: `search_pro_jina`
            - `search_domain_filter` string — Limits search results to specified whitelisted domains. Whitelist: input domains directly (e.g., www.example.com) Supported engines: `search_pro_jina`
            - `search_recency_filter` 'oneDay' | 'oneWeek' | 'oneMonth' | 'oneYear' | 'noLimit' — Limits search to a specific time range. Default is `noLimit` Values: `oneDay`, within a day `oneWeek`, within a week `oneMonth`, within a month `oneYear`, within a year `noLimit`, no limit (default) Supported engines: `search_pro_jina`
            - `content_size` 'medium' | 'high' — Number of characters for webpage summaries. Default is `medium` `medium`: Balanced mode for most queries. 400-600 characters `high`: Maximizes context for comprehensive answers, 2500 characters.
            - `result_sequence` 'before' | 'after' — Specifies whether search results are shown before or after model response. Options: `before`, `after`. Default is `after`
            - `search_result` boolean — Whether to return search results in the response. Default is `false`
            - `require_search` boolean — Whether to force model response based on search result. Default is `false`
            - `search_prompt` string — Prompt to customize how search results are processed. Default Prompt: `You are an intelligent Q&A expert with the ability to synthesize information, recognize time, understand semantics, and clean contradictory data. The current date is {{current_date}}. Use this as the only time reference. Based on the following information, provide a comprehensive and accurate answer to the user's question.Only extract valuable content for the answer. Ensure the answer is timely and authoritative. State the answer directly without citing data sources or internal processes.`
    - `tool_choice` 'auto' — 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[] — 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 — Specifies the response format of the model. Defaults to text. Only text models support this field. `type` converges to three values: `text` (plain text output), `json_object` (JSON output).
      - `type` 'text' | 'json_object', required — Output format type: text for plain text, json_object for JSON-formatted output.
    - `request_id` string — Passed by the user side, needs to be unique; used to distinguish each request, 6–64 characters. If not provided by the user side, the platform will generate one by default.
    - `user_id` string — Unique ID for the end user, 6–128 characters. Avoid using sensitive information.
  - ChatCompletionVisionRequest
    - `model` 'glm-5v-turbo' | 'glm-4.6v' | 'autoglm-phone-multilingual' | 'glm-4.6v-flash' | 'glm-4.6v-flashx' | 'glm-4.5v', required — The model code to be called. GLM-5V-Turbo are the new generation of visual reasoning models. `AutoGLM-Phone-Multilingual` is mobile intelligent assistant model.
    - `messages` union[], required — 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. Note: The input must not consist of system or assistant messages only.
      - union
        - object
          - `role` 'user', required — Role of the message author
          - `content` union, required
            - VisionMultimodalContentItem[] — Multimodal message content, supports text, images, video, file
              - …
            - string — Text message content (can switch to multimodal message above)
        - object
          - `role` 'system', required — Role of the message author
          - `content` string, required — Message text content
        - object — Can include tool calls
          - `role` 'assistant', required — Role of the message author
          - `content` string — Text message content
    - `do_sample` boolean — 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. Default value is `true`.
    - `stream` boolean — 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` ChatThinking — Only supported by GLM-4.5 series and higher models. This parameter is used to control whether the model enable the chain of thought.
      - `type` 'enabled' | 'disabled' — Whether to enable the chain of thought(`GLM-5.3` can only be enabled, and the thinking depth is controlled by `reasoning_effort`; for other models, when enabled, GLM-5.2 GLM-5.1 GLM-5 GLM-5-Turbo GLM-5V-Turbo GLM-4.6 GLM-4.5 and others will automatically determine whether to think, while GLM-4.7 and GLM-4.5V will think compulsorily), default: enabled
      - `clear_thinking` boolean — Default value is True. Controls whether to clear `reasoning_content` from previous conversation turns. View more in [Thinking Mode](/guides/capabilities/thinking-mode). - `true` (default): For this request, the system ignores/removes `reasoning_content` from prior turns, and only keeps non-reasoning context (e.g., user/assistant visible text, tool calls, and tool results). This is recommended for general chat or lightweight tasks to reduce context length and cost. - `false`: Retains `reasoning_content` from prior turns and includes it in the context sent to the model. To enable Preserved Thinking, you must forward the full, unmodified, and correctly ordered historical `reasoning_content` in `messages`. Missing, truncated, rewritten, or reordered blocks may degrade performance or prevent the feature from taking effect. - Notes: This parameter only affects cross-turn historical thinking blocks; it does not change whether the model generates/returns thinking in the current turn.
    - `temperature` number, float — Sampling temperature, controls the randomness of the output, must be a positive number within the range: `[0.0, 1.0]`. The GLM-5V-Turbo, GLM-4.6V, GLM-4.5V series default value is `0.8`, the autoglm-phone-multilingual default value is `0.0`.
    - `top_p` number, float — Another method of temperature sampling, value range is: `[0.01, 1.0]`, value range is: `[0.01, 1.0]`. The GLM-5V-Turbo, GLM-4.6V, GLM-4.5V series default value is `0.6`, the autoglm-phone-multilingual default value is `0.85`.
    - `max_tokens` integer — The maximum number of tokens for model output, the GLM-5V-Turbo supports 128K maximum output, GLM-4.6V series supports 32K maximum output, the GLM-4.5V series supports 16K maximum output, the autoglm-phone-multilingual supports 4K maximum output.
    - `tools` FunctionToolSchema[] — A list of tools the model may call. Only support by GLM-4.6V series and autoglm-phone-multilingual. Use this to provide a list of functions the model may generate JSON inputs for. A max of 128 functions are supported.
      - `type` 'function', required
      - `function` FunctionObject, required
        - `name` string, required — The name of the function to be called. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64.
        - `description` string, required — A description of what the function does, used by the model to choose when and how to call the function.
        - `parameters` FunctionParameters, required — Parameters defined using JSON Schema. Must pass a JSON Schema object to accurately define accepted parameters. Omit if no parameters are needed when calling the function.
    - `tool_choice` 'auto' — 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[] — Stop word list. Generation stops when the model encounters any specified string. Currently, only one stop word is supported, in the format ["stop_word1"].
    - `request_id` string — Passed by the user side, needs to be unique; used to distinguish each request, 6–64 characters. If not provided by the user side, the platform will generate one by default.
    - `user_id` string — Unique ID for the end user, 6–128 characters. Avoid using sensitive information.

## Response `200`

Processing successful

- ChatCompletionResponse
  - `id` string — Task ID
  - `request_id` string — Request ID
  - `created` integer — Request creation time, Unix timestamp in seconds
  - `model` string — Model name
  - `choices` object[] — List of model responses
    - `index` integer — Result index.
    - `message` ChatCompletionResponseMessage
      - `role` string — Current conversation role, default is ‘assistant’ (model)
      - `content` string — Current conversation content. Hits function is null, otherwise returns model inference result. For the GLM-4.5V series models, the output may contain the reasoning process tags `<think> </think>` or the text boundary tags `<|begin_of_box|> <|end_of_box|>`.
      - `reasoning_content` string — Reasoning content, supports by GLM-4.5 series.
      - `tool_calls` ChatCompletionResponseMessageToolCall[] — Function names and parameters generated by the model that should be called.
        - `function` object — Contains the function name and JSON format parameters generated by the model.
          - `name` string, required — Model-generated function name.
          - `arguments` object, required — JSON format of the function call parameters generated by the model. Validate the parameters before calling the function.
        - `id` string — Unique identifier for the hit function.
        - `type` string — Tool type called by the model, currently only supports ‘function’.
    - `finish_reason` string — Reason for model inference termination. Can be `stop`, `tool_calls`, `length`, `sensitive`, `model_context_window_exceeded` or `network_error`.
  - `usage` object — Token usage statistics returned when the model call ends.
    - `prompt_tokens` number — Number of tokens in user input
    - `completion_tokens` number — Number of output tokens
    - `prompt_tokens_details` object
      - `cached_tokens` number — Number of tokens served from cache
    - `total_tokens` integer — Total number of tokens
  - `web_search` WebSearchObjectResponse[] — Search results.
    - `title` string — Title.
    - `content` string — Content summary.
    - `link` string — Result URL.
    - `media` string — Website name.
    - `icon` string — Website icon.
    - `refer` string — Index number.
    - `publish_date` string — Website publication date.

## Other responses

- `default` — The request has failed.

---

[API](https://skmtc.net/z/apis/z-ai-api.md) · [All operations](https://skmtc.net/z/apis/z-ai-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/z/z-ai-api/revisions/242a797fa80b/schema)
