> ## 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 All-Model API - Messages Reference

> - Call GLM series models through the Anthropic Messages protocol, choosing the specific model with the `model` parameter
- The request and response structures match the Anthropic API
- **System prompt**: passed through the top-level `system` field
- **Thinking mode**: thinking is on by default across the series and is returned in `content[type=thinking]` blocks; only `glm-5.2` can turn it off with `thinking.type=disabled`
- **Streaming**: SSE event stream
- **Tool calling**: compatible with the Anthropic `tool_use` / `tool_result` flow
- **Image input**: genuinely supported only by `glm-5.3-flash`; see the `messages` field for details

<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>

<Note>
  **Whether thinking can be turned off varies by model**: only `glm-5.2` supports `thinking.type: "disabled"`; `glm-5.3` and `glm-5.3-flash` always think and return an error if `disabled` is sent. When migrating from `glm-5.2`, remove the hard-coded `disabled` before switching models.
</Note>

<Warning>
  **Image input is supported only by `glm-5.3-flash`, and sending images to the other models does not raise an error.** When image content blocks go to `glm-5.3` or `glm-5.2`, the request returns 200 as usual, but the model cannot read the image and answers from the text alone — a plausible-looking reply that has nothing to do with the image, and one that is not consistent across requests. This kind of silent failure is hard to track down in production, so choose `glm-5.3-flash` when you need image understanding.
</Warning>


## OpenAPI

````yaml en/api-manual/language-series/glm/messages/messages-reference.json POST /v1/messages
openapi: 3.1.0
info:
  title: GLM All-Model API - Messages Reference
  description: >-
    Full API reference for calling Zhipu GLM text models through the Anthropic
    Messages protocol.


    **Models covered**: `glm-5.3`, `glm-5.3-flash`, `glm-5.2` (selected with the
    `model` parameter)


    **Compatibility notes**:

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

    - The request and 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`


    **Shared capabilities**:

    - 1M token context window, up to 131,072 tokens of output

    - Thinking mode: **thinking is on by default** across the series; it is
    returned in `content[type=thinking]` blocks and counts towards output tokens

    - Prompt caching: an implicit prefix cache that repeated requests with the
    same prefix hit automatically (reported in `cache_read_input_tokens`), with
    no need to set `cache_control`; `cache_creation_input_tokens` is always 0


    **Differences between models** (whether thinking can be turned off, whether
    images can be read) are described in the `model`, `thinking` and `messages`
    fields below.
  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 endpoints
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: GLM Messages (All Models, Anthropic-Compatible)
      description: >-
        - Call GLM series models through the Anthropic Messages protocol,
        choosing the specific model with the `model` parameter

        - The request and response structures match the Anthropic API

        - **System prompt**: passed through the top-level `system` field

        - **Thinking mode**: thinking is on by default across the series and is
        returned in `content[type=thinking]` blocks; only `glm-5.2` can turn it
        off with `thinking.type=disabled`

        - **Streaming**: SSE event stream

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

        - **Image input**: genuinely supported only by `glm-5.3-flash`; see the
        `messages` field for details
      operationId: createMessageGLM
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMessageRequest'
            examples:
              simple:
                summary: Minimal runnable request
                value:
                  model: glm-5.3
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: Hello, world
              system_prompt:
                summary: With a system prompt
                value:
                  model: glm-5.3
                  max_tokens: 2048
                  system: You are a seasoned technical editor.
                  messages:
                    - role: user
                      content: Introduce GLM-5.3 in three sentences.
              stop_sequences:
                summary: Custom stop sequences
                value:
                  model: glm-5.3
                  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.3
                  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.3
                  max_tokens: 1024
                  stream: true
                  messages:
                    - role: user
                      content: Write a short poem about spring
              disable_thinking_glm52_only:
                summary: Disable thinking mode (glm-5.2 only)
                value:
                  model: glm-5.2
                  max_tokens: 512
                  thinking:
                    type: disabled
                  messages:
                    - role: user
                      content: 'In one sentence: what is the capital of Japan?'
                description: >-
                  Only `glm-5.2` can turn thinking off. Sending
                  `thinking.type=disabled` to `glm-5.3` or `glm-5.3-flash`
                  returns an error.
              vision_flash:
                summary: Image input (glm-5.3-flash only)
                description: >-
                  `glm-5.3-flash` supports vision natively. Images are passed in
                  through `image` content blocks, and `source` accepts both
                  `base64` and `url`.
                value:
                  model: glm-5.3-flash
                  max_tokens: 1024
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: What is in this image?
                        - type: image
                          source:
                            type: base64
                            media_type: image/png
                            data: <BASE64_ENCODED_IMAGE>
      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.3
                    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.3
                    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: Upstream service 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: >
            Model to call:


            | Model ID | Positioning | Thinking can be turned off | Image input
            |

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

            | `glm-5.3` | Flagship model, with across-the-board gains on complex
            software engineering and agent tasks; 1M context | Cannot be turned
            off | Not supported |

            | `glm-5.3-flash` | Lightweight multimodal model, extremely low cost
            with native vision; 1M context | Cannot be turned off | Supported |

            | `glm-5.2` | Previous-generation flagship, complex reasoning and
            very long context; 1M context | Can be turned off
            (`thinking.type=disabled`) | Not supported |
          enum:
            - glm-5.3
            - glm-5.3-flash
            - glm-5.2
          example: glm-5.3
          default: glm-5.3
        max_tokens:
          type: integer
          description: >-
            Upper limit on the length of the generated content (in tokens)


            **Note**:

            - The GLM series supports up to **131,072 tokens** (128K) of output;
            setting at least `1024` is recommended

            - Tokens produced by thinking also count towards this limit

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


            **Note**:

            - At least one message is required

            - The last message is normally `role=user`

            - Multi-turn context is supported and the model draws on the history


            **Image input**: only `glm-5.3-flash` supports it, through a
            `{"type":"image","source":{...}}` block inside the `content` array.


            Sending image content blocks to `glm-5.3` or `glm-5.2` **does not
            return an error, but the model cannot read the image**. The request
            returns 200 as usual, and the model answers from the text alone,
            producing a plausible-looking reply that has nothing to do with the
            image — and the result is not consistent across requests.


            This kind of silent failure is hard to track down in production, so
            choose `glm-5.3-flash` when you need image understanding.
          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, the GLM series 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


            **Note**:

            - Every model in the GLM series is a reasoning model, and **thinking
            is on by default when this field is omitted**

            - When it is on, the response `content` array contains a
            `type="thinking"` reasoning block (billed as output tokens;
            `signature` may be an empty string)

            - **Only the binary `type` switch takes effect**: thinking budget or
            level parameters such as `budget_tokens` and `effort` have no effect
            (they are ignored)


            **Whether it can be turned off depends on the model**:

            - `glm-5.2`: sending `{"type":"disabled"}` turns thinking off and
            cuts output tokens noticeably

            - `glm-5.3` / `glm-5.3-flash`: **always think, cannot be turned
            off**. Sending `disabled` returns an error


            **The consequence: the `glm-5.3` series cannot reduce thinking
            overhead on this endpoint.** It cannot be turned off (`disabled`
            errors),

            and it cannot be turned down either (`budget_tokens` and `effort`
            both have no effect, and the top-level `reasoning_effort` is an
            OpenAI-protocol field that this endpoint ignores).

            Thinking content is billed as output tokens, so on this endpoint
            that cost is unavoidable.


            **To control thinking cost, switch to the [Chat Completions
            API](../chat-completions/chat-completions-reference)** —

            there, `reasoning_effort` has three levels that genuinely take
            effect: `low` / `high` / `max`. `glm-5.2` is not subject to this
            limit; it can turn thinking off directly on this endpoint.


            **Migrating from `glm-5.2`**: if your code hard-codes
            `thinking.type=disabled`, you must remove that field before
            switching to `glm-5.3`, otherwise the request fails outright.

            And if you relied on turning thinking off to control cost, this
            endpoint offers no equivalent — plan to move to the Chat Completions
            API as part of the switch.
          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: Model actually used
          example: glm-5.3
        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


            **Note**:

            - For plain text, pass a string directly

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

            - `image` content blocks are **supported only by `glm-5.3-flash`**;
            sending them to any other model does not return an error, but the
            model cannot read the image
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentBlock'
    CacheControl:
      type: object
      description: >-
        Prompt cache marker


        **Note**: the GLM series uses an implicit cache (built automatically
        from identical prefixes, hits shown in `cache_read_input_tokens`, needs
        warming up) and does not rely on this explicit marker; `cache_control`
        can be sent normally but may be ignored, and it does not affect the
        implicit cache.
      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: Text when type=`text`
        thinking:
          type: string
          description: The reasoning-process text when type=`thinking`
        signature:
          type: string
          description: Signature when type=`thinking` (may be an empty string)
        id:
          type: string
          description: Tool call ID when type=`tool_use`
        name:
          type: string
          description: 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 specification)
      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 tokens written to the cache. The GLM series uses implicit
            caching with no explicit cache-creation step, so **this field is
            always 0**.
          example: 0
        cache_read_input_tokens:
          type: integer
          description: >-
            Number of input tokens served from the implicit prefix cache.
            Repeated requests with the same prefix hit it automatically, with no
            need to set `cache_control`; the cached portion is billed at the
            cache rate, which is markedly lower than the uncached input rate.
            The first request returns 0.
          example: 0
        prompt_tokens_details:
          type: object
          description: >-
            Input token breakdown (cache-hit fields, also returned by the GLM
            series)
          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

        - `image`: image (**`glm-5.3-flash` only**; other models do not return
        an error but cannot read the image)

        - `tool_use`: replay of the previous assistant tool call

        - `tool_result`: tool execution result

        - `thinking`: replay of the previous assistant thinking content
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - image
            - tool_use
            - tool_result
            - thinking
        text:
          type: string
          description: Text content when type=`text`
        source:
          type: object
          description: >-
            Image source (required when type=`image`, **supported only by
            `glm-5.3-flash`**)


            Both inline `base64` and `url` are supported.
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - base64
                - url
              description: >-
                How the image is supplied


                - `base64`: inline image data

                - `url`: a public image URL, downloaded by the upstream service
                itself
            media_type:
              type: string
              description: Image MIME type (required when `type=base64`)
              example: image/png
            data:
              type: string
              description: >-
                Base64-encoded image data (required when `type=base64`, without
                the `data:` prefix)
              example: iVBORw0KGgoAAAANSUhEUgAA...
            url:
              type: string
              description: Public image URL (required when `type=url`)
              example: https://example.com/photo.jpg
        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 returned thinking content; it must be passed
            back unchanged when continuing a multi-turn conversation (may be 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`.

````