> ## 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 - Chat Completions Quickstart

> - Call GLM series models through the OpenAI Chat Completions protocol, choosing the specific model with the `model` parameter
- `model` and `messages` are the only parameters you need
- 1M token context window across the series, with up to 131,072 output tokens
- Deep thinking is on by default across the series, and the reasoning is returned in `reasoning_content`
- For streaming, tool calls, thinking-depth control, image input and other capabilities, see the Reference page

<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/chat-completions/chat-completions-quickstart.json POST /v1/chat/completions
openapi: 3.1.0
info:
  title: GLM All-Model API - Chat Completions Quickstart
  description: >-
    A quickstart example for calling Zhipu GLM text models through the
    OpenAI-compatible Chat Completions API. Just `model` and `messages` are
    enough to start a conversation; for the full parameter set, see the
    Reference page.
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: Production (recommended)
  - url: https://api.evolink.ai
    description: Alternative URL
security:
  - bearerAuth: []
tags:
  - name: Chat Completion
    description: AI chat completion related endpoints
paths:
  /v1/chat/completions:
    post:
      tags:
        - Chat Completion
      summary: GLM Quick Chat (All Models)
      description: >-
        - Call GLM series models through the OpenAI Chat Completions protocol,
        choosing the specific model with the `model` parameter

        - `model` and `messages` are the only parameters you need

        - 1M token context window across the series, with up to 131,072 output
        tokens

        - Deep thinking is on by default across the series, and the reasoning is
        returned in `reasoning_content`

        - For streaming, tool calls, thinking-depth control, image input and
        other capabilities, see the Reference page
      operationId: glmChatCompletionsQuick
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChatCompletionQuickRequest'
            examples:
              simple:
                summary: Minimal call
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: Hello, please introduce yourself in one sentence
              flash:
                summary: Switch to the lightweight model
                description: >-
                  `glm-5.3-flash` costs far less than `glm-5.3` and suits
                  high-frequency calls.
                value:
                  model: glm-5.3-flash
                  messages:
                    - role: user
                      content: Explain what HTTP is in one sentence
              multi_turn:
                summary: Multi-turn conversation
                value:
                  model: glm-5.3
                  messages:
                    - role: user
                      content: >-
                        Recommend a programming language that is good for
                        beginners
                    - role: assistant
                      content: 'I recommend Python: concise syntax and a rich ecosystem.'
                    - role: user
                      content: Roughly how long does it take to learn?
      responses:
        '200':
          description: Chat completion generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChatCompletionResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 400
                  message: Invalid request parameters
                  type: invalid_request_error
        '401':
          description: Unauthorized, invalid or expired token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                error:
                  code: 401
                  message: Invalid or expired token
                  type: authentication_error
        '402':
          description: Insufficient quota, recharge required
          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: Access denied
          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: Resource not found
          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: Rate limit exceeded
          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: Internal server error
          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: Upstream service error
          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: Service temporarily unavailable
          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:
    ChatCompletionQuickRequest:
      title: Chat Completion Quick Request
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: >
            Model to call:


            | Model ID | Positioning |

            |---|---|

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

            | `glm-5.3-flash` | Lightweight multimodal model, extremely low
            cost, native image input; 1M context |

            | `glm-5.2` | Previous-generation flagship, complex reasoning and
            very long context; 1M context |
          enum:
            - glm-5.3
            - glm-5.3-flash
            - glm-5.2
          default: glm-5.3
          example: glm-5.3
        messages:
          type: array
          description: >-
            The list of conversation messages, in chronological order. At least
            one message is required.
          minItems: 1
          items:
            $ref: '#/components/schemas/MessageSimple'
    ChatCompletionResponse:
      type: object
      properties:
        id:
          type: string
          description: Task `ID`
          example: chatcmpl-a6613b56-c61c-94ba-9a9f-43d4cdc7d77a
        object:
          type: string
          description: Response type
          enum:
            - chat.completion
          example: chat.completion
        request_id:
          type: string
          description: Request `ID` (returned when `request_id` is provided in the request)
          example: req-7f3a2c1e8b9d4f0a
        created:
          type: integer
          description: Request creation time, `Unix` timestamp (seconds)
          example: 1777021417
        model:
          type: string
          description: Model name
          example: glm-5.3
        choices:
          type: array
          description: The list of model responses
          items:
            $ref: '#/components/schemas/Choice'
        usage:
          $ref: '#/components/schemas/Usage'
        content_filter:
          type: array
          description: Content safety-related information
          items:
            $ref: '#/components/schemas/ContentFilter'
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: integer
              description: HTTP status error code
            message:
              type: string
              description: Error description
            type:
              type: string
              description: Error type
            param:
              type: string
              description: Related parameter name
            fallback_suggestion:
              type: string
              description: Suggestion when error occurs
    MessageSimple:
      title: Message
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - system
            - user
            - assistant
          description: |-
            Message role

            - `system`: system prompt
            - `user`: user input
            - `assistant`: model reply (included in multi-turn conversations)
          example: user
        content:
          type: string
          description: Message content (plain text)
          example: Hello, please introduce yourself in one sentence
    Choice:
      type: object
      properties:
        index:
          type: integer
          description: Result index
          example: 0
        message:
          $ref: '#/components/schemas/AssistantMessage'
        finish_reason:
          type: string
          description: >-
            The reason inference terminated


            - `stop`: Natural completion or a stop word was triggered

            - `tool_calls`: The model triggered a function (tool call)

            - `length`: Reached the token length limit

            - `sensitive`: Content was blocked by safety review (please assess
            and decide whether to retract public content)

            - `network_error`: Model inference error

            - `model_context_window_exceeded`: Exceeded the model's context
            window
          enum:
            - stop
            - tool_calls
            - length
            - sensitive
            - network_error
            - model_context_window_exceeded
          example: stop
    Usage:
      type: object
      description: Token usage statistics returned when the call ends
      properties:
        prompt_tokens:
          type: integer
          description: The number of tokens in the user input
          example: 24
        completion_tokens:
          type: integer
          description: >-
            The number of output tokens (including the chain-of-thought
            `reasoning_tokens` portion)
          example: 346
        total_tokens:
          type: integer
          description: Total token count = prompt_tokens + completion_tokens
          example: 370
        prompt_tokens_details:
          type: object
          description: Detailed breakdown of input tokens
          properties:
            cached_tokens:
              type: integer
              description: The number of tokens that hit the cache
              example: 0
        completion_tokens_details:
          type: object
          description: Detailed breakdown of output tokens
          properties:
            reasoning_tokens:
              type: integer
              description: >-
                The number of tokens produced by the chain of thought (deep
                thinking), counted toward `completion_tokens`
              example: 321
    ContentFilter:
      type: object
      description: Content safety information
      properties:
        role:
          type: string
          description: |-
            The stage where safety takes effect

            - `assistant`: Model inference
            - `user`: User input
            - `history`: Historical context
          enum:
            - assistant
            - user
            - history
        level:
          type: integer
          description: >-
            Severity level `0-3`, where `0` indicates the most severe and `3`
            indicates minor
          minimum: 0
          maximum: 3
    AssistantMessage:
      type: object
      properties:
        role:
          type: string
          description: The current conversation role, defaults to `assistant`
          enum:
            - assistant
          example: assistant
        content:
          type:
            - string
            - 'null'
          description: >-
            Conversation text content


            **Notes**: May be `null` when calling tools (`tool_calls`);
            otherwise returns the model's reply content
          example: >-
            Hello! I'm GLM-5.3, and I can help you with a variety of tasks such
            as conversation, reasoning, writing, and code.
        reasoning_content:
          type: string
          description: >-
            Chain-of-thought content


            **Notes**: Returned when `thinking` is enabled, recording the
            model's reasoning process
          example: Let me first analyze this problem...
        tool_calls:
          type: array
          description: >-
            Generated tool call information (returned when the model decides to
            call a tool)
          items:
            type: object
            properties:
              id:
                type: string
                description: Unique identifier of the tool call
              type:
                type: string
                description: Tool call type
                enum:
                  - function
              function:
                type: object
                description: >-
                  Function call information (containing the generated function
                  name and JSON-formatted arguments)
                properties:
                  name:
                    type: string
                    description: The generated function name
                  arguments:
                    type: string
                    description: >-
                      The JSON-formatted string of function call arguments;
                      please validate the arguments before calling the function
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        ##All APIs require Bearer Token authentication##


        **Get API Key:**


        Visit [API Key Management Page](https://evolink.ai/dashboard/keys) to
        get your API Key


        **Add to request header:**

        ```

        Authorization: Bearer YOUR_API_KEY

        ```

````