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

# GLM 全模型接口 - Chat Completions 完整参数

> - 使用 OpenAI Chat Completions 协议调用 GLM 系列模型，通过 `model` 参数选择具体型号
- 同步处理模式，实时返回对话内容
- **文本对话**：单轮或多轮上下文对话；`glm-5.3-flash` 额外支持图像输入
- **系统提示词**：通过 `role=system` 消息自定义 AI 的角色和行为
- **深度思考**：`thinking.type` 控制思维链，`reasoning_effort` 调节推理强度；推理过程通过 `reasoning_content` 返回
- **流式输出**：支持 SSE 流式返回（`stream=true`）
- **工具调用**：支持 Function Calling、网络搜索（`web_search`，最多 128 个工具）
- **结构化输出**：通过 `response_format` 启用 JSON 模式

**流式响应说明**：当 `stream=true` 时，通过 Server-Sent Events 返回，每条消息格式为 `data: {JSON}`，结束时返回 `data: [DONE]`。每个数据块（`ChatCompletionChunk`）包含 `id`、`created`、`model`、`choices`、可选 `usage` 与 `content_filter`；其中 `choices[].delta` 增量返回 `role` / `content` / `reasoning_content` / `tool_calls`，`choices[].finish_reason` 在最后一块给出终止原因。

<Note>
  **BaseURL 说明**：默认 BaseURL 为 `https://direct.evolink.ai`，对文本模型支持更好，支持长连接；`https://api.evolink.ai` 是多模态主力地址，对文本模型作为备用地址使用。
</Note>

<Note>
  **思考控制因模型而异**：`glm-5.3` 与 `glm-5.3-flash` 始终思考、无法关闭，`reasoning_effort` 三档 `low` / `high` / `max` 生效，其余档位自动降级到最接近的可用档（`xhigh` → `max`、`medium` → `high`、`minimal` / `none` → `low`，仍会思考并按 output 计费）；`glm-5.2` 可通过 `thinking.type: "disabled"` 关闭思考，并支持更多推理档位。详见 `thinking` 与 `reasoning_effort` 字段说明。
</Note>

<Note>
  **图像输入**：仅 `glm-5.3-flash` 支持，通过 `messages[].content[]` 的 `image_url` 内容块传入。其余模型传入图像块会报错。
</Note>


## OpenAPI

````yaml cn/api-manual/language-series/glm/chat-completions/chat-completions-reference.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: GLM 全模型接口 - Chat Completions 完整参数
  description: >-
    通过 OpenAI 兼容的 Chat Completions 接口调用智谱 GLM 系列文本模型的完整 API 参考。


    **收录模型**：`glm-5.3`、`glm-5.3-flash`、`glm-5.2`（用 `model` 参数选择）


    **通用能力**：

    - 1M token 上下文窗口，最大输出 **131,072 tokens**（128K），建议不小于 **1,024 tokens**

    - 深度思考：`thinking` 字段控制思维链，`reasoning_effort` 调节推理强度；推理过程通过
    `reasoning_content` 返回

    - 工具调用：Function Calling、网络搜索（最多 128 个工具）

    - 流式输出：SSE 流式返回

    - 结构化输出：`text` / `json_object` 两种响应格式

    - 上下文缓存：隐式前缀缓存，相同前缀的重复请求自动命中，命中部分体现在
    `usage.prompt_tokens_details.cached_tokens`


    **模型间差异**（思考控制、图像输入）见下方 `model` 与 `thinking` / `reasoning_effort` 字段说明。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
tags:
  - name: 对话生成
    description: AI 对话生成相关接口
paths:
  /v1/chat/completions:
    post:
      tags:
        - 对话生成
      summary: GLM 对话接口（全模型，OpenAI 兼容）
      description: >-
        - 使用 OpenAI Chat Completions 协议调用 GLM 系列模型，通过 `model` 参数选择具体型号

        - 同步处理模式，实时返回对话内容

        - **文本对话**：单轮或多轮上下文对话；`glm-5.3-flash` 额外支持图像输入

        - **系统提示词**：通过 `role=system` 消息自定义 AI 的角色和行为

        - **深度思考**：`thinking.type` 控制思维链，`reasoning_effort` 调节推理强度；推理过程通过
        `reasoning_content` 返回

        - **流式输出**：支持 SSE 流式返回（`stream=true`）

        - **工具调用**：支持 Function Calling、网络搜索（`web_search`，最多 128 个工具）

        - **结构化输出**：通过 `response_format` 启用 JSON 模式


        **流式响应说明**：当 `stream=true` 时，通过 Server-Sent Events 返回，每条消息格式为 `data:
        {JSON}`，结束时返回 `data: [DONE]`。每个数据块（`ChatCompletionChunk`）包含
        `id`、`created`、`model`、`choices`、可选 `usage` 与 `content_filter`；其中
        `choices[].delta` 增量返回 `role` / `content` / `reasoning_content` /
        `tool_calls`，`choices[].finish_reason` 在最后一块给出终止原因。
      operationId: createChatCompletionGLM
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionRequest'
            examples:
              simple_text:
                summary: 单轮文本对话
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 请介绍一下你自己
              multi_turn:
                summary: 多轮对话（上下文理解）
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 什么是 Python？
                    - role: assistant
                      content: Python 是一种高级编程语言……
                    - role: user
                      content: 它有什么优点？
              system_prompt:
                summary: 使用系统提示词
                value:
                  model: glm-5.3
                  messages:
                    - role: system
                      content: 你是一个专业的 Python 编程助手，用简洁的语言回答问题。
                    - role: user
                      content: 如何读取文件？
              deep_thinking:
                summary: 开启深度思考并调节推理强度
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 一个农夫要带狼、羊和白菜过河，每次只能带一样，如何安全过河？
                  thinking:
                    type: enabled
                  reasoning_effort: max
              function_calling:
                summary: 工具调用（Function Calling）
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 北京今天天气怎么样？
                  tools:
                    - type: function
                      function:
                        name: get_weather
                        description: 查询指定城市的实时天气
                        parameters:
                          type: object
                          properties:
                            city:
                              type: string
                              description: 城市名称，例如：北京
                          required:
                            - city
                  tool_choice: auto
              web_search:
                summary: 启用网络搜索工具
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 帮我查一下最近一周的人工智能新闻
                  tools:
                    - type: web_search
                      web_search:
                        enable: true
                        count: 10
                        search_recency_filter: oneWeek
                description: >-
                  模型判断需要联网时会自动检索，检索结果并入上下文参与推理。检索结果按输入 token
                  计费，搜索服务本身另按次计费（详见定价页）；模型未触发搜索时不产生搜索费用。
              json_mode:
                summary: JSON 结构化输出
                value:
                  model: glm-5.3
                  messages:
                    - role: system
                      content: 请以 JSON 格式输出，包含 name 和 age 两个字段。
                    - role: user
                      content: 张三，今年 28 岁
                  response_format:
                    type: json_object
              streaming:
                summary: 流式输出（SSE）
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 写一首关于春天的短诗
                  stream: true
              disable_thinking_glm52_only:
                summary: 关闭深度思考（仅 glm-5.2 支持）
                value:
                  model: glm-5.2
                  messages:
                    - role: user
                      content: 用一句话总结相对论。
                  thinking:
                    type: disabled
                description: >-
                  只有 `glm-5.2` 可以关闭思考。`glm-5.3` 与 `glm-5.3-flash` 传
                  `thinking.type: "disabled"` 会报错，请改用 `reasoning_effort: "low"`。
              low_effort:
                summary: 降低思考开销（glm-5.3 系列关闭思考的替代方案）
                description: '`glm-5.3` 系列无法关闭思考，用 `reasoning_effort: "low"` 把推理强度降到最低。'
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: 用一句话解释 HTTP
                  thinking:
                    type: enabled
                  reasoning_effort: low
                  max_tokens: 1024
              vision_flash:
                summary: 图像输入（仅 glm-5.3-flash）
                description: >-
                  `glm-5.3-flash` 原生支持视觉，图像通过 `image_url` 内容块传入，可用公网 URL 或
                  Base64 Data URL。
                value:
                  model: glm-5.3-flash
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: 这张图里是什么？
                        - type: image_url
                          image_url:
                            url: https://example.com/photo.jpg
                  max_tokens: 1024
      responses:
        '200':
          description: 对话生成成功
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: 请求参数错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 400
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: 未认证、Token无效或过期
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: 配额不足、需要充值
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 402
                  message: Insufficient quota
                  type: insufficient_quota_error
                  fallback_suggestion: https://evolink.ai/dashboard/billing
        '403':
          description: 无权限访问
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 403
                  message: Access denied for this model
                  type: permission_error
                  param: model
        '404':
          description: 资源不存在
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 404
                  message: Specified model not found
                  type: not_found_error
                  param: model
                  fallback_suggestion: glm-5.3
        '429':
          description: 请求频率超限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 429
                  message: Rate limit exceeded
                  type: rate_limit_error
                  fallback_suggestion: retry after 60 seconds
        '500':
          description: 服务器内部错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 500
                  message: Internal server error
                  type: internal_server_error
                  fallback_suggestion: try again later
        '502':
          description: 上游服务错误
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 502
                  message: Upstream AI service unavailable
                  type: upstream_error
                  fallback_suggestion: try different model
        '503':
          description: 服务暂时不可用
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 503
                  message: Service temporarily unavailable
                  type: service_unavailable_error
                  fallback_suggestion: retry after 30 seconds
components:
  schemas:
    ChatCompletionRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: >
            要调用的模型：


            | 模型 ID | 定位 | 思考控制 | 图像输入 |

            |---|---|---|---|

            | `glm-5.3` | 旗舰模型，复杂软件工程与 Agent 任务能力全面进阶，编程能力较上代大幅提升；1M 上下文 |
            始终思考，不可关闭；`reasoning_effort` 仅 `low` / `high` / `max` 生效，其余档位自动降级 |
            不支持 |

            | `glm-5.3-flash` | 轻量多模态模型，稀疏注意力与线性注意力混合架构，成本极低且原生支持视觉；1M 上下文 | 同
            `glm-5.3` | **支持**，见 `messages` 字段 |

            | `glm-5.2` | 上一代旗舰，复杂推理与超长上下文；1M 上下文 | 可用 `thinking.type:
            "disabled"` 关闭；`reasoning_effort` 支持 7 档 | 不支持 |
          enum:
            - glm-5.3
            - glm-5.3-flash
            - glm-5.2
          default: glm-5.3
          example: glm-5.3
        messages:
          type: array
          description: >-
            对话消息列表，包含当前对话的完整上下文信息


            支持四种角色：`system`、`user`、`assistant`、`tool`。不同角色的消息具有不同的字段结构，请选择对应角色查看。至少包含
            1 条消息，且不能只包含系统消息或助手消息。
          items:
            oneOf:
              - $ref: '#/components/schemas/SystemMessage'
              - $ref: '#/components/schemas/UserMessage'
              - $ref: '#/components/schemas/AssistantRequestMessage'
              - $ref: '#/components/schemas/ToolMessage'
            discriminator:
              propertyName: role
              mapping:
                system:
                  $ref: '#/components/schemas/SystemMessage'
                user:
                  $ref: '#/components/schemas/UserMessage'
                assistant:
                  $ref: '#/components/schemas/AssistantRequestMessage'
                tool:
                  $ref: '#/components/schemas/ToolMessage'
          minItems: 1
        stream:
          type: boolean
          description: >-
            是否启用流式输出模式


            - `false`：模型生成完整响应后一次性返回（默认），适合短文本与批处理

            - `true`：通过 Server-Sent Events（SSE）实时逐块返回，适合聊天与长文本；流式结束时返回 `data:
            [DONE]`
          default: false
          example: false
        thinking:
          type: object
          description: 控制是否开启思维链（Chain of Thought）
          properties:
            type:
              type: string
              description: >-
                思维链开关


                - `enabled`：开启深度思考（所有模型的默认行为）

                - `disabled`：关闭深度思考，模型直接回答


                **只有 `glm-5.2` 支持 `disabled`。** `glm-5.3` 与 `glm-5.3-flash`
                始终思考，传入 `disabled` 会报错。


                在 `glm-5.3` 系列上想降低思考开销，请改用 `reasoning_effort: "low"`。


                **从 `glm-5.2` 迁移**：如果现有代码写死了 `thinking.type: "disabled"`，换成
                `glm-5.3` 前必须先改为 `"enabled"`（想降低思考开销可再配 `reasoning_effort:
                "low"`），否则请求会直接失败。


                注意这两个字段的处理方式**不一样**：`reasoning_effort` 传了该系列不支持的档位会自动降级、不报错；而
                `thinking.type` 是显式开关，传 `disabled` 一定报错、不会被静默改写。所以只把
                `reasoning_effort` 从 `none` 改成 `low` 是不够的，`thinking.type`
                也得一并改掉。
              enum:
                - enabled
                - disabled
              default: enabled
            clear_thinking:
              type: boolean
              description: >-
                是否清除历史对话轮次中的 `reasoning_content`


                - `true`（默认）：忽略/移除历史轮次的
                `reasoning_content`，仅用非推理内容（用户/助手可见文本、工具调用与结果等）作为上下文，可降低上下文长度与成本

                - `false`：保留历史轮次的 `reasoning_content` 并随上下文提供给模型（Preserved
                Thinking）；此时必须在 `messages` 中**完整、未修改、按原顺序**透传历史
                `reasoning_content`，缺失、裁剪、改写或重排会导致效果下降或无法生效

                - 注意：该参数只影响跨轮次的历史思考，不改变当前轮是否产生思考
              default: true
              example: true
        reasoning_effort:
          type: string
          description: >-
            控制模型的推理程度，仅在 `thinking` 开启时生效，默认 `max`


            **取值支持情况按模型区分**：


            | 取值 | `glm-5.3` / `glm-5.3-flash` | `glm-5.2` |

            |---|---|---|

            | `max` | 深度推理（默认） | 深度推理 |

            | `high` | 增强推理 | 增强推理 |

            | `low` | 轻量推理 | 等价 `high` |

            | `xhigh` | 降级为 `max` | 等价 `max` |

            | `medium` | 降级为 `high` | 等价 `high` |

            | `minimal` | 降级为 `low`（仍会思考） | 放弃思考 |

            | `none` | 降级为 `low`（仍会思考） | 放弃思考 |


            `glm-5.3` 系列始终思考，三档 `low` / `high` / `max`
            真实生效；其余四档不会报错，会自动降级到最接近的可用档（`xhigh` → `max`、`medium` →
            `high`、`minimal` / `none` → `low`）。


            **`glm-5.3` 系列无法关闭思考。** 传 `minimal` 或 `none` 只是降到最低档 `low`，模型仍会产生思考
            token，并**按 output 价计费**。如果你传这两档是为了省钱，请注意这与 `glm-5.2` 不同——在 `glm-5.2`
            上它们是真的放弃思考。


            编程等复杂任务建议用 `max`。
          enum:
            - max
            - xhigh
            - high
            - medium
            - low
            - minimal
            - none
          default: max
          example: max
        do_sample:
          type: boolean
          description: |-
            是否启用采样策略

            - `true`（默认）：使用 `temperature` / `top_p` 进行随机采样，输出更多样
            - `false`：总是选择概率最高的词汇（贪心解码），输出更确定，此时 `temperature` 与 `top_p` 被忽略

            对需要一致性、可重复性的任务（如代码生成、翻译），建议设置为 `false`
          default: true
          example: true
        temperature:
          type: number
          format: float
          description: |-
            采样温度，控制输出的随机性和创造性

            **说明**：
            - 取值范围：`[0.0, 1.0]`，限两位小数
            - 较高值（如 0.8）：更随机、更有创意，适合创意写作
            - 较低值（如 0.2）：更稳定、更确定，适合事实问答与代码生成
            - 默认值：`1.0`

            **建议**：不要同时调整 `temperature` 和 `top_p`
          minimum: 0
          maximum: 1
          default: 1
          example: 1
        top_p:
          type: number
          format: float
          description: |-
            核采样（Nucleus Sampling）参数，是 `temperature` 采样的替代方法

            **说明**：
            - 取值范围：`[0.01, 1.0]`，限两位小数
            - 模型只考虑累积概率达到 `top_p` 的候选词汇，例如 0.1 表示只考虑前 10% 概率的词汇
            - 较小值产生更集中、更一致的输出；较大值增加多样性
            - 默认值：`0.95`

            **建议**：不要同时调整 `temperature` 和 `top_p`
          minimum: 0.01
          maximum: 1
          default: 0.95
          example: 0.95
        max_tokens:
          type: integer
          description: |-
            模型输出的最大 token 数量限制

            **说明**：
            - GLM 系列最大支持 **131,072 tokens**（128K）输出长度，建议设置不小于 `1024`
            - 开启 `thinking` 时，思维链 token 也计入该上限
            - 若生成因 `length` 原因被截断，请尝试调高此值
          minimum: 1
          maximum: 131072
          example: 1024
        tools:
          type: array
          description: |-
            模型可以调用的工具列表

            **说明**：
            - 支持函数调用（`function`）与网络搜索（`web_search`）
            - 最多支持 128 个函数
            - 其中 `web_search` 在实际发生搜索时**按次单独计费**，其余工具不额外收费
          items:
            oneOf:
              - $ref: '#/components/schemas/FunctionTool'
              - $ref: '#/components/schemas/WebSearchTool'
            discriminator:
              propertyName: type
              mapping:
                function:
                  $ref: '#/components/schemas/FunctionTool'
                web_search:
                  $ref: '#/components/schemas/WebSearchTool'
          maxItems: 128
        tool_choice:
          type: string
          description: |-
            控制模型选择调用哪个函数的方式

            **说明**：仅在工具类型为 `function` 时生效，默认且仅支持 `auto`（由模型自动决定是否调用工具）
          enum:
            - auto
          default: auto
          example: auto
        stop:
          type: array
          description: |-
            停止词列表

            **说明**：
            - 当模型生成文本遇到指定字符串时立即停止生成（停止词本身不包含在返回文本中）
            - 目前仅支持单个停止词，格式为 `["stop_word1"]`，例如 `["Human:"]`
          items:
            type: string
          maxItems: 4
          example:
            - 'Human:'
        response_format:
          type: object
          description: >-
            指定模型响应输出格式，默认为 `text`


            **说明**：

            - `{ "type": "json_object" }` 启用 JSON 模式，模型返回有效的 JSON
            格式数据，适用于结构化数据提取等场景

            - 使用 JSON 模式时，建议在 `system` 或 `user` 消息中明确要求输出 JSON
          required:
            - type
          properties:
            type:
              type: string
              description: |-
                输出格式类型

                - `text`：普通文本输出（默认）
                - `json_object`：JSON 格式输出
              enum:
                - text
                - json_object
              default: text
        request_id:
          type: string
          description: |-
            请求唯一标识符

            **说明**：
            - 由用户端传递，长度 6-64 字符，建议使用 UUID 格式确保唯一性
            - 若未提供，平台将自动生成
          minLength: 6
          maxLength: 64
          example: req-7f3a2c1e8b9d4f0a
        user_id:
          type: string
          description: |-
            终端用户的唯一标识符

            **说明**：长度 6-128 字符，建议使用不包含敏感信息的唯一标识，可帮助平台监控和检测滥用行为
          minLength: 6
          maxLength: 128
          example: user-abc123456
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: 任务 `ID`
          example: chatcmpl-a6613b56-c61c-94ba-9a9f-43d4cdc7d77a
        object:
          type: string
          description: 响应类型
          enum:
            - chat.completion
          example: chat.completion
        request_id:
          type: string
          description: 请求 `ID`（在请求中提供 `request_id` 时回传）
          example: req-7f3a2c1e8b9d4f0a
        created:
          type: integer
          description: 请求创建时间，`Unix` 时间戳（秒）
          example: 1777021417
        model:
          type: string
          description: 模型名称
          example: glm-5.3
        choices:
          type: array
          description: 模型响应列表
          items:
            $ref: '#/components/schemas/Choice'
        usage:
          $ref: '#/components/schemas/Usage'
        web_search:
          type: array
          description: 网页搜索相关信息，使用 `web_search` 工具且命中搜索时返回
          items:
            $ref: '#/components/schemas/WebSearchResult'
        content_filter:
          type: array
          description: 内容安全相关信息
          items:
            $ref: '#/components/schemas/ContentFilter'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP 状态错误代码
            message:
              type: string
              description: 错误描述信息
            type:
              type: string
              description: 错误类型
            param:
              type: string
              description: 相关参数名称
            fallback_suggestion:
              type: string
              description: 错误时的建议
    SystemMessage:
      title: System Message
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
          description: 角色标识，固定为 `system`
        content:
          type: string
          description: 系统提示词内容，用于设定 AI 的角色和行为
    UserMessage:
      title: User Message
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
          description: 角色标识，固定为 `user`
        content:
          description: |-
            用户消息内容。

            - **字符串**：纯文本，所有模型均支持
            - **内容块数组**：文本与图像混排，**仅 `glm-5.3-flash` 支持**

            向 `glm-5.3` 或 `glm-5.2` 传入图像内容块会报错。
          oneOf:
            - type: string
              title: 纯文本
              description: 纯文本消息内容
              example: 你好，请介绍一下你自己
            - type: array
              title: 内容块数组（仅 glm-5.3-flash）
              description: >-
                文本与图像混排。图像通过 `image_url` 块传入，可传公网 URL（推荐）或 Base64 Data URL；多图放多个
                `image_url` 块。
              items:
                $ref: '#/components/schemas/ContentPart'
    AssistantRequestMessage:
      title: Assistant Message
      type: object
      description: 助手消息，可包含工具调用
      required:
        - role
      properties:
        role:
          type: string
          enum:
            - assistant
          description: 角色标识，固定为 `assistant`
        content:
          type:
            - string
            - 'null'
          description: |-
            助手消息内容

            **说明**：用于多轮对话中传递历史助手回复；当存在 `tool_calls` 时通常为 `null`
        reasoning_content:
          type:
            - string
            - 'null'
          description: >-
            历史思维链内容


            **说明**：仅当 `thinking.clear_thinking=false`（Preserved
            Thinking）时需要，将上一轮响应的 `reasoning_content`
            原样回传；默认（`clear_thinking=true`）无需回传
        tool_calls:
          type: array
          description: |-
            工具调用列表

            用于在多轮对话中传递历史的工具调用信息；提供此字段时 `content` 通常为空
          items:
            type: object
            required:
              - id
              - type
            properties:
              id:
                type: string
                description: 工具调用 ID
              type:
                type: string
                enum:
                  - function
                  - web_search
                description: 工具类型
              function:
                type: object
                description: 函数调用信息，当 `type` 为 `function` 时不为空
                required:
                  - name
                  - arguments
                properties:
                  name:
                    type: string
                    description: 函数名称
                  arguments:
                    type: string
                    description: 函数参数（JSON 格式字符串）
    ToolMessage:
      title: Tool Message
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - tool
          description: 角色标识，固定为 `tool`
        content:
          type: string
          description: 工具调用的返回结果内容
        tool_call_id:
          type: string
          description: 指示此消息对应的工具调用 `ID`（对应 assistant 消息 `tool_calls` 返回的 `id`）
    FunctionTool:
      title: Function 工具
      type: object
      required:
        - type
        - function
      additionalProperties: false
      properties:
        type:
          type: string
          enum:
            - function
          default: function
          description: 工具类型，固定为 `function`
        function:
          type: object
          required:
            - name
            - description
            - parameters
          properties:
            name:
              type: string
              description: |-
                要调用的函数名称

                **说明**：必须由 `a-z`、`A-Z`、`0-9` 字符组成，或包含下划线和破折号；最大长度 64 字符
              minLength: 1
              maxLength: 64
              pattern: ^[a-zA-Z0-9_-]+$
            description:
              type: string
              description: 函数功能的描述，供模型选择何时以及如何调用函数
            parameters:
              type: object
              description: 函数的输入参数，以 JSON Schema 对象描述
    WebSearchTool:
      title: Web Search 工具（网络搜索）
      type: object
      required:
        - type
        - web_search
      additionalProperties: false
      properties:
        type:
          type: string
          enum:
            - web_search
          default: web_search
          description: 工具类型，固定为 `web_search`
        web_search:
          type: object
          required:
            - enable
          properties:
            enable:
              type: boolean
              description: 是否启用搜索功能，启用时设置为 `true`
              default: false
            search_query:
              type: string
              description: 强制触发搜索的自定义关键词
            search_intent:
              type: boolean
              description: |-
                是否进行搜索意图识别，默认执行

                - `true`：执行搜索意图识别，有搜索意图后执行搜索
                - `false`：跳过意图识别，直接执行搜索
            count:
              type: integer
              description: >-
                返回结果的条数，范围 `1-50`，默认 `10`。


                条数直接影响成本：检索结果会并入 `prompt_tokens` 按输入价计费，取 `50` 时单次输入可达两万 token
                量级。除非确实需要更广的召回，建议保持默认。
              minimum: 1
              maximum: 50
              default: 10
            search_domain_filter:
              type: string
              description: 限定搜索结果的域名白名单（如 `www.example.com`）
            search_recency_filter:
              type: string
              description: 限定搜索结果的时间范围，默认 `noLimit`
              enum:
                - oneDay
                - oneWeek
                - oneMonth
                - oneYear
                - noLimit
              default: noLimit
            content_size:
              type: string
              description: |-
                控制网页摘要的字数，默认 `medium`

                - `medium`：返回摘要信息，满足基础推理需求
                - `high`：最大化上下文，信息更详细
              enum:
                - medium
                - high
              default: medium
            result_sequence:
              type: string
              description: 搜索结果返回的位置（在模型回复之前或之后），默认 `after`
              enum:
                - before
                - after
              default: after
            search_result:
              type: boolean
              description: >-
                是否在响应中返回搜索来源的详细信息，默认 `false`。


                设为 `true` 时，响应顶层会附带 `web_search`
                数组，列出本次检索到的来源（标题、链接、媒体来源、发布时间、摘要等）；保持默认则响应中不包含该字段。


                该参数只影响响应内容，不影响是否执行搜索，也不影响计费。
              default: false
              example: true
            require_search:
              type: boolean
              description: 是否强制基于搜索结果才返回回答，默认 `false`
              default: false
            search_prompt:
              type: string
              description: 用于定制搜索结果处理的 `Prompt`，不传时使用默认模板
      description: >-
        网络搜索工具。开启后模型可在需要时联网检索，并把检索结果并入上下文。


        **计费**：搜索结果并入上下文的部分按 `prompt_tokens` 计入输入价；搜索服务本身**按调用次数单独计费**，与 token
        用量分开结算，详见定价页。是否触发搜索由模型按搜索意图判断，未触发搜索则不产生该费用。
    Choice:
      type: object
      properties:
        index:
          type: integer
          description: 结果索引
          example: 0
        message:
          $ref: '#/components/schemas/AssistantMessage'
        finish_reason:
          type: string
          description: |-
            推理终止原因

            - `stop`：自然结束或触发停止词
            - `tool_calls`：模型命中函数（工具调用）
            - `length`：达到 token 长度限制
            - `sensitive`：内容被安全审核拦截（请判断并决定是否撤回公开内容）
            - `network_error`：模型推理异常
            - `model_context_window_exceeded`：超出模型上下文窗口
          enum:
            - stop
            - tool_calls
            - length
            - sensitive
            - network_error
            - model_context_window_exceeded
          example: stop
    Usage:
      type: object
      description: 调用结束时返回的 Token 使用统计
      properties:
        prompt_tokens:
          type: integer
          description: 用户输入的 token 数量
          example: 24
        completion_tokens:
          type: integer
          description: 输出的 token 数量（含思维链 `reasoning_tokens` 部分）
          example: 346
        total_tokens:
          type: integer
          description: token 总数 = prompt_tokens + completion_tokens
          example: 370
        prompt_tokens_details:
          type: object
          description: 输入 token 详细分项
          properties:
            cached_tokens:
              type: integer
              description: >-
                命中上下文缓存的输入 token 数量。


                GLM
                系列为**隐式前缀缓存**：相同前缀的重复请求自动命中，无需任何额外参数；命中部分按缓存价计费，显著低于未命中的输入价。首次请求为
                0，之后同前缀请求即可命中。
              example: 0
        completion_tokens_details:
          type: object
          description: 输出 token 详细分项
          properties:
            reasoning_tokens:
              type: integer
              description: 思维链（深度思考）产生的 token 数量，计入 `completion_tokens`
              example: 321
    WebSearchResult:
      type: object
      description: 单条网页搜索结果
      properties:
        icon:
          type: string
          description: 来源网站的图标
        title:
          type: string
          description: 搜索结果的标题
        link:
          type: string
          description: 搜索结果的网页链接
        media:
          type: string
          description: 搜索结果网页的媒体来源名称
        publish_date:
          type: string
          description: 网站发布时间
        content:
          type: string
          description: 搜索结果网页引用的文本内容
        refer:
          type: string
          description: 角标序号
    ContentFilter:
      type: object
      description: 内容安全信息
      properties:
        role:
          type: string
          description: |-
            安全生效环节

            - `assistant`：模型推理
            - `user`：用户输入
            - `history`：历史上下文
          enum:
            - assistant
            - user
            - history
        level:
          type: integer
          description: 严重程度 `0-3`，`0` 表示最严重，`3` 表示轻微
          minimum: 0
          maximum: 3
    ContentPart:
      title: Content Part
      type: object
      description: 多模态内容块。**仅 `glm-5.3-flash` 支持图像块。**
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - image_url
          description: |-
            内容块类型

            - `text`：文本
            - `image_url`：图像（仅 `glm-5.3-flash`）
        text:
          type: string
          description: 文本内容，`type=text` 时必填
          example: 这张图里是什么？
        image_url:
          type: object
          description: 图像内容，`type=image_url` 时必填
          required:
            - url
          properties:
            url:
              type: string
              description: >-
                图像地址。支持公网 HTTPS URL（推荐）或 Base64 Data
                URL（`data:image/png;base64,...`）
              example: https://example.com/photo.jpg
    AssistantMessage:
      type: object
      properties:
        role:
          type: string
          description: 当前对话角色，默认 `assistant`
          enum:
            - assistant
          example: assistant
        content:
          type:
            - string
            - 'null'
          description: |-
            对话文本内容

            **说明**：调用工具（`tool_calls`）时可能为 `null`，否则返回模型回复内容
          example: 你好！我是 GLM-5.3，可以帮你完成对话、推理、写作、代码等多种任务。
        reasoning_content:
          type: string
          description: |-
            思维链内容

            **说明**：在 `thinking` 开启时返回，记录模型的推理过程
          example: 让我先分析这个问题……
        tool_calls:
          type: array
          description: 生成的工具调用信息（当模型决定调用工具时返回）
          items:
            type: object
            properties:
              id:
                type: string
                description: 工具调用的唯一标识符
              type:
                type: string
                description: 工具调用类型
                enum:
                  - function
              function:
                type: object
                description: 函数调用信息（包含生成的函数名称和 JSON 格式参数）
                properties:
                  name:
                    type: string
                    description: 生成的函数名称
                  arguments:
                    type: string
                    description: 函数调用参数的 JSON 格式字符串，调用函数前请验证参数
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |-
        ##所有接口均需要使用 Bearer Token 进行认证##

        **获取 API Key**：

        访问 [API Key 管理页面](https://evolink.ai/dashboard/keys) 获取您的 API Key

        **使用时在请求头中添加**：
        ```
        Authorization: Bearer YOUR_API_KEY
        ```

````