> ## 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-5.2 - Anthropic Compatible API

> - Call the GLM-5.2 model via the Anthropic Messages protocol
- Request / response structures aligned with the Anthropic API
- **System prompt**: Passed via the top-level `system` field
- **Thinking mode**: GLM-5.2 has thinking enabled by default; thinking content is returned via `content[type=thinking]` blocks; pass `thinking.type=disabled` to turn it off
- **Streaming output**: SSE event stream
- **Tool calling**: Compatible with the Anthropic `tool_use` / `tool_result` flow
- ⚠️ **No multimodal support**: GLM-5.2 is a text-only model, and image / video content blocks are ignored

<Note>
  **BaseURL**: The default BaseURL is `https://direct.evolink.ai`, which has better support for text models and long-lived connections. `https://api.evolink.ai` is the primary endpoint for multimodal services and serves as a fallback address for text models.
</Note>


## OpenAPI

````yaml en/api-manual/language-series/glm-5.2/glm-5.2-messages.json POST /v1/messages
openapi: 3.1.0
info:
  title: GLM-5.2 Anthropic-Compatible API
  description: >-
    Complete API reference for calling GLM-5.2 via the Anthropic Messages
    protocol.


    **Compatibility notes**:

    - Path: `/v1/messages` (Anthropic standard path)

    - Request / response structures match the Anthropic Messages API

    - Supported fields: `model` `messages` (required) `system` `max_tokens`
    `temperature` `top_p` `top_k` `stop_sequences` `stream` `thinking` `tools`
    `tool_choice` `metadata`


    **Model capabilities**:

    - Thinking mode: GLM-5.2 is a reasoning model and **has thinking enabled by
    default**; thinking content is returned via `content[type=thinking]` blocks
    and counts toward output tokens. When not needed, explicitly pass
    `thinking.type=disabled` to turn it off and save tokens

    - **Text-only model**: ⚠️ Does not support multimodal inputs such as images
    / video (image content blocks passed in are ignored)

    - Prompt caching: Implicit caching is supported, and requests with the same
    prefix automatically hit the cache (reflected in `cache_read_input_tokens`,
    with no need to set `cache_control` manually); the cache needs to warm up,
    and hits become more stable after the same prefix is requested several
    times; `cache_creation_input_tokens` is always 0
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: Production (Recommended, better support for text models)
  - url: https://api.evolink.ai
    description: Alternative URL
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Anthropic Messages protocol interface
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: GLM-5.2 Messages Interface (Anthropic-Compatible)
      description: >-
        - Call the GLM-5.2 model via the Anthropic Messages protocol

        - Request / response structures aligned with the Anthropic API

        - **System prompt**: Passed via the top-level `system` field

        - **Thinking mode**: GLM-5.2 has thinking enabled by default; thinking
        content is returned via `content[type=thinking]` blocks; pass
        `thinking.type=disabled` to turn it off

        - **Streaming output**: SSE event stream

        - **Tool calling**: Compatible with the Anthropic `tool_use` /
        `tool_result` flow

        - ⚠️ **No multimodal support**: GLM-5.2 is a text-only model, and image
        / video content blocks are ignored
      operationId: createMessageGLM52
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMessageRequest'
            examples:
              simple:
                summary: Minimal runnable request
                value:
                  model: glm-5.2
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: Hello, world
              system_prompt:
                summary: With a system prompt
                value:
                  model: glm-5.2
                  max_tokens: 2048
                  system: You are a seasoned technical editor.
                  messages:
                    - role: user
                      content: Introduce GLM-5.2 in three sentences.
              disable_thinking:
                summary: Disable thinking mode (save tokens)
                value:
                  model: glm-5.2
                  max_tokens: 512
                  thinking:
                    type: disabled
                  messages:
                    - role: user
                      content: 'In one sentence: what is the capital of Japan?'
              stop_sequences:
                summary: Custom stop sequences
                value:
                  model: glm-5.2
                  max_tokens: 50
                  thinking:
                    type: disabled
                  stop_sequences:
                    - '3'
                  messages:
                    - role: user
                      content: 'Output exactly: 1 2 3 4 5 6'
              tool_use:
                summary: Tool calling (Anthropic tool_use style)
                value:
                  model: glm-5.2
                  max_tokens: 2048
                  messages:
                    - role: user
                      content: Check the weather in Tokyo and tell me
                  tools:
                    - name: get_weather
                      description: Query the current weather of a specified city
                      input_schema:
                        type: object
                        properties:
                          city:
                            type: string
                            description: 'City name, for example: Tokyo'
                        required:
                          - city
                  tool_choice:
                    type: auto
              streaming:
                summary: Streaming output (SSE)
                value:
                  model: glm-5.2
                  max_tokens: 1024
                  stream: true
                  messages:
                    - role: user
                      content: Write a short poem about spring
      responses:
        '200':
          description: Message object
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
              examples:
                with_thinking:
                  summary: Includes a thinking content block by default
                  value:
                    id: msg_0842a705-9d0b-4eaa-b12d-09a4106326c5
                    type: message
                    role: assistant
                    model: glm-5.2
                    content:
                      - type: thinking
                        thinking: >-
                          The user asked to greet them with one word, so
                          answering "Hi" will do.
                        signature: ''
                      - type: text
                        text: Hi.
                    stop_reason: end_turn
                    usage:
                      input_tokens: 18
                      output_tokens: 101
                      cache_creation_input_tokens: 0
                      cache_read_input_tokens: 0
                      prompt_tokens_details:
                        cached_tokens: 0
                tool_use:
                  summary: Triggers a tool call (stop_reason=tool_use)
                  value:
                    id: msg_067e85db-53df-43a1-bd38-09c53375f2f0
                    type: message
                    role: assistant
                    model: glm-5.2
                    content:
                      - type: tool_use
                        id: toolu_36b8a98e284c426799f08612
                        name: get_weather
                        input:
                          city: Tokyo
                    stop_reason: tool_use
                    usage:
                      input_tokens: 161
                      output_tokens: 11
                      cache_creation_input_tokens: 0
                      cache_read_input_tokens: 0
                      prompt_tokens_details:
                        cached_tokens: 0
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                request_id: req_xxx
                error:
                  type: invalid_request_error
                  message: Invalid request
        '401':
          description: Authentication error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: authentication_error
                  message: Authentication error
        '402':
          description: Insufficient quota
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: billing_error
                  message: Insufficient quota
        '403':
          description: Permission error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: permission_error
                  message: Permission denied
        '404':
          description: Model or resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: not_found_error
                  message: Model not found
        '429':
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: rate_limit_error
                  message: Rate limited
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: Gateway error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: Service temporarily unavailable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateMessageRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: The model to call
          enum:
            - glm-5.2
          example: glm-5.2
        max_tokens:
          type: integer
          description: >-
            The upper limit on the length of generated content (number of
            tokens)


            **Notes**:

            - Tokens produced by thinking also count toward this limit

            - When the limit is reached, content is truncated and the response
            returns `stop_reason=max_tokens`
          minimum: 1
          example: 1024
        messages:
          type: array
          description: >-
            The list of conversation messages, alternating between user /
            assistant by turn


            **Notes**:

            - Must contain at least 1 message

            - The last message is usually `role=user`

            - Multi-turn context is supported, and the model references prior
            messages
          items:
            $ref: '#/components/schemas/InputMessage'
          minItems: 1
        system:
          description: >-
            System prompt, used to set the AI's role and behavior


            **Notes**:

            - Supports a string or an array of content blocks

            - Passed via the top-level `system` field (do not place it inside
            messages)

            - The model follows the system constraints

            - ⚠️ **An overly long system may be truncated**: For long context,
            place it in `messages` rather than piling everything into `system`
          oneOf:
            - type: string
              example: You are a helpful assistant.
            - type: array
              description: >-
                System prompt in content-block array format. text blocks may
                carry cache_control
              items:
                type: object
                required:
                  - type
                  - text
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
                  cache_control:
                    $ref: '#/components/schemas/CacheControl'
        temperature:
          type: number
          description: >-
            Sampling temperature


            **Notes**:

            - Higher values make output more varied, lower values more
            deterministic

            - Recommended range `[0, 1]`
          minimum: 0
          maximum: 1
          example: 1
        top_p:
          type: number
          description: >-
            Nucleus sampling threshold


            **Notes**:

            - Range `[0, 1]`

            - It is recommended not to adjust temperature and top_p at the same
            time
          minimum: 0
          maximum: 1
          example: 0.9
        top_k:
          type: integer
          description: >-
            Sample only from the K highest-probability tokens (an
            Anthropic-specific parameter)


            **Notes**:

            - Smaller values make output more deterministic, larger values make
            candidates more diverse
          minimum: 0
          example: 10
        stop_sequences:
          type: array
          description: >-
            Custom stop sequences: generation stops when it hits any of these
            strings


            **Notes**:

            - Hitting one truncates output, and content before the hit is
            returned normally

            - ⚠️ **Note**: When a stop sequence is hit, GLM-5.2 returns
            `stop_reason` as `end_turn` (rather than the Anthropic-standard
            `stop_sequence`), and the response does not include a
            `stop_sequence` field. If your client relies on
            `stop_reason=="stop_sequence"` to detect a hit, special handling is
            required
          items:
            type: string
          example:
            - |+


        stream:
          type: boolean
          description: >-
            Whether to return via SSE streaming


            - `true`: Server-Sent Events streaming (standard Anthropic event
            sequence: message_start / content_block_start / content_block_delta
            / message_delta / message_stop)

            - `false`: Returns the complete response all at once (default)
          default: false
          example: false
        thinking:
          type: object
          description: >-
            Controls deep thinking


            **Notes**:

            - GLM-5.2 is a reasoning model, and **thinking is enabled by default
            when this field is not passed**

            - When enabled, the response `content` array includes a
            `type="thinking"` reasoning-process block (billed as output tokens,
            and `signature` may be an empty string)

            - Pass `{"type":"disabled"}` to turn off thinking, significantly
            reducing output tokens

            - ⚠️ **Only the binary `type` toggle takes effect**: thinking budget
            / level parameters such as `budget_tokens` and `effort` have no
            effect (they are ignored), so the amount of thinking cannot be
            finely controlled
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - enabled
                - disabled
              description: |-
                - Not passing the thinking field: thinking is enabled by default
                - `disabled`: turn off thinking and answer directly
                - `enabled`: the Anthropic-standard explicit enable value
        tools:
          type: array
          description: >-
            The list of tool definitions


            **Notes**:

            - Follows the Anthropic tool definition spec

            - `input_schema` uses a JSON Schema object

            - The model returns standard `tool_use` blocks with
            `stop_reason=tool_use`
          items:
            $ref: '#/components/schemas/Tool'
        tool_choice:
          type: object
          description: Tool selection strategy
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - auto
                - none
              description: |-
                - `auto`: the model decides on its own whether to call a tool
                - `none`: tool calls are disallowed
        metadata:
          type: object
          description: Request metadata
          properties:
            user_id:
              type: string
              description: >-
                A unique identifier representing the end user, which can be used
                for per-user monitoring and abuse detection (using a hashed ID
                is recommended)
    MessageResponse:
      type: object
      description: Anthropic-style message response
      properties:
        id:
          type: string
          description: 'The message''s unique ID (format: `msg_<uuid>`)'
        type:
          type: string
          enum:
            - message
          description: Response object type
        role:
          type: string
          enum:
            - assistant
        model:
          type: string
          description: The model actually used
          example: glm-5.2
        content:
          type: array
          description: >-
            The list of response content blocks


            **Possible block types**:

            - `thinking`: the reasoning process (when thinking is enabled, which
            is the default)

            - `text`: the final answer text

            - `tool_use`: a tool call initiated by the model
          items:
            $ref: '#/components/schemas/OutputContentBlock'
        stop_reason:
          type: string
          description: >-
            Stop reason


            - `end_turn`: natural completion (⚠️ also returned when
            stop_sequences is hit)

            - `max_tokens`: reached the max_tokens limit

            - `tool_use`: the model triggered a tool call
          enum:
            - end_turn
            - max_tokens
            - tool_use
        usage:
          $ref: '#/components/schemas/AnthropicUsage'
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - error
        error:
          type: object
          properties:
            type:
              type: string
              description: >-
                Error type (e.g. invalid_request_error / authentication_error /
                billing_error, etc.)
            message:
              type: string
              description: Error description
        request_id:
          type: string
          description: Request tracing ID
    InputMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          description: >-
            The role of the message sender, alternating between user / assistant


            - `user`: user message (also used to pass back `tool_result` blocks)

            - `assistant`: the assistant's historical replies (may contain
            `text` / `thinking` / `tool_use` blocks)


            ⚠️ **`system` is not accepted**: pass system prompts via the
            top-level `system` field.
        content:
          description: >-
            Message content


            **Notes**:

            - For plain text, pass a string directly

            - For structured content, pass an array of content blocks (`text` /
            `tool_use` / `tool_result` / `thinking`)

            - ⚠️ GLM-5.2 is a text-only model, and `image` / `video` content
            blocks are ignored
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentBlock'
    CacheControl:
      type: object
      description: >-
        Prompt caching marker


        **Notes**: GLM-5.2 uses implicit caching (built automatically per
        identical prefix, with hits shown in `cache_read_input_tokens`, and
        requires warm-up) and does not rely on this explicit marker;
        `cache_control` can be passed normally but may be ignored, and it does
        not affect implicit caching.
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - ephemeral
          description: Cache marker type
    Tool:
      type: object
      required:
        - name
        - input_schema
      properties:
        name:
          type: string
          description: |-
            Tool name

            **Notes**:
            - Only `a-zA-Z0-9_-` are allowed
            - Maximum 64 characters
        description:
          type: string
          description: >-
            A description of the tool's capability, for the model to decide when
            to call it
        input_schema:
          type: object
          description: |-
            The JSON Schema object for the tool's input parameters

            **Notes**:
            - `type` must be `object`
            - Should declare `properties` and `required`
        cache_control:
          $ref: '#/components/schemas/CacheControl'
    OutputContentBlock:
      type: object
      description: A content block in the response
      properties:
        type:
          type: string
          enum:
            - text
            - thinking
            - tool_use
        text:
          type: string
          description: The text when type=`text`
        thinking:
          type: string
          description: The reasoning-process text when type=`thinking`
        signature:
          type: string
          description: >-
            The signature when type=`thinking` (GLM-5.2 may return an empty
            string)
        id:
          type: string
          description: The tool call ID when type=`tool_use`
        name:
          type: string
          description: The tool name when type=`tool_use`
        input:
          type: object
          description: >-
            The JSON input parameters generated by the model when
            type=`tool_use`
    AnthropicUsage:
      type: object
      description: Token usage statistics (Anthropic spec)
      properties:
        input_tokens:
          type: integer
          description: Number of input tokens (the portion not served from cache)
          example: 18
        output_tokens:
          type: integer
          description: Number of output tokens (including thinking)
          example: 101
        cache_creation_input_tokens:
          type: integer
          description: >-
            Number of input tokens used for cache creation (always 0 for
            GLM-5.2)
          example: 0
        cache_read_input_tokens:
          type: integer
          description: >-
            Number of input tokens served from cache (when an implicit cache
            hits, roughly the length of the shared prefix)
          example: 0
        prompt_tokens_details:
          type: object
          description: Input token breakdown (cache-hit fields, also returned by GLM-5.2)
          properties:
            cached_tokens:
              type: integer
              description: Number of input tokens served from cache
              example: 0
    ContentBlock:
      type: object
      description: |-
        Message content block

        **Supported types**:
        - `text`: text content
        - `tool_use`: passes back a previous-turn assistant tool call
        - `tool_result`: tool execution result
        - `thinking`: passes back previous-turn assistant thinking content

        ⚠️ Does not support `image` / `video` (text-only model)
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - tool_use
            - tool_result
            - thinking
        text:
          type: string
          description: The text content when type=`text`
        id:
          type: string
          description: Tool call ID (required for tool_use)
        name:
          type: string
          description: Tool name (required for tool_use)
        input:
          type: object
          description: Tool input parameters (for tool_use, a JSON object)
        tool_use_id:
          type: string
          description: >-
            The corresponding tool call ID (required for tool_result, filled
            back from tool_use.id)
        content:
          description: >-
            Tool execution result (tool_result), a string or an array of content
            blocks
          oneOf:
            - type: string
            - type: array
              items:
                type: object
        thinking:
          type: string
          description: >-
            The passed-back assistant thinking-process content (used when
            type=`thinking`)
        signature:
          type: string
          description: >-
            The signature of the passed-back thinking content, which must be
            passed back as-is for multi-turn continuation (GLM-5.2 may return an
            empty string)
        cache_control:
          $ref: '#/components/schemas/CacheControl'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##All interfaces require authentication using a Bearer Token##


        **Get an API Key**:


        Visit the [API Key management page](https://evolink.ai/dashboard/keys)
        to obtain your API Key


        **Add it to the request header when using**:

        ```

        Authorization: Bearer YOUR_API_KEY

        ```


        **Note**: EvoLink uses Bearer Token authentication uniformly for
        `/v1/messages`.

````