> ## 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 全モデルインターフェース - Messages クイックスタート

> - Anthropic Messages プロトコルで GLM シリーズのモデルを呼び出し（モデルは `model` パラメータで選択）
- 必要なパラメータは `model`、`max_tokens`、`messages` の 3 つだけ（`max_tokens` は Anthropic プロトコルで必須）
- 全シリーズで 1M token のコンテキストウィンドウ、最大出力 131,072 tokens
- 全シリーズで**デフォルトで思考が有効**。レスポンスの `content` に `type="thinking"` ブロックが含まれ、この部分は output トークンに計上されます
- ストリーミング出力、ツール呼び出し、画像入力などの機能は「完全なパラメータ」ページをご覧ください

<Note>
  **BaseURL**：デフォルトの BaseURL は `https://direct.evolink.ai` で、テキストモデルへの対応が優れており、長時間接続をサポートします。`https://api.evolink.ai` はマルチモーダルサービスの主力エンドポイントで、テキストモデルに対しては代替アドレスとして使用されます。
</Note>

<Note>
  **GLM シリーズはデフォルトで思考が有効です。** レスポンスの `content` 配列に `type="thinking"` ブロックが含まれ、この部分は output トークンに計上されます。そのため `max_tokens` を小さくしすぎないでください。1024 以上を推奨します。小さすぎると、思考が終わらないうちに打ち切られ、本文が得られない場合があります。
</Note>


## OpenAPI

````yaml ja/api-manual/language-series/glm/messages/messages-quickstart.json POST /v1/messages
openapi: 3.1.0
info:
  title: GLM 全モデルインターフェース - Messages クイックスタート
  description: >-
    Anthropic Messages プロトコルで Zhipu GLM
    シリーズのテキストモデルを呼び出すクイックスタート例。`model`、`max_tokens`、`messages` の 3
    つのパラメータだけで対話を開始できます。完全なパラメータは「完全なパラメータ」ページをご覧ください。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 本番環境（推奨、テキストモデルへの対応が優れています）
  - url: https://api.evolink.ai
    description: 代替 URL
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Anthropic Messages プロトコルインターフェース
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: GLM クイック対話（全モデル、Anthropic 互換）
      description: >-
        - Anthropic Messages プロトコルで GLM シリーズのモデルを呼び出し（モデルは `model` パラメータで選択）

        - 必要なパラメータは `model`、`max_tokens`、`messages` の 3 つだけ（`max_tokens` は
        Anthropic プロトコルで必須）

        - 全シリーズで 1M token のコンテキストウィンドウ、最大出力 131,072 tokens

        - 全シリーズで**デフォルトで思考が有効**。レスポンスの `content` に `type="thinking"`
        ブロックが含まれ、この部分は output トークンに計上されます

        - ストリーミング出力、ツール呼び出し、画像入力などの機能は「完全なパラメータ」ページをご覧ください
      operationId: glmMessagesQuick
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMessageQuickRequest'
            examples:
              simple:
                summary: 最小構成の呼び出し
                value:
                  model: glm-5.3
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: こんにちは、一文で自己紹介してください
              flash:
                summary: 軽量モデルに切り替え
                description: '`glm-5.3-flash` は `glm-5.3` よりコストが大幅に低く、高頻度の呼び出しに適しています。'
                value:
                  model: glm-5.3-flash
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: HTTP とは何かを一文で説明してください
              multi_turn:
                summary: マルチターン対話
                value:
                  model: glm-5.3
                  max_tokens: 1024
                  messages:
                    - role: user
                      content: 入門に適したプログラミング言語を教えてください
                    - role: assistant
                      content: Python がおすすめです。構文が簡潔で、エコシステムも豊富です。
                    - role: user
                      content: それを習得するにはどれくらいかかりますか？
      responses:
        '200':
          description: メッセージオブジェクト
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
              examples:
                with_thinking:
                  summary: デフォルトで thinking content block を含む
                  value:
                    id: msg_0842a705-9d0b-4eaa-b12d-09a4106326c5
                    type: message
                    role: assistant
                    model: glm-5.3
                    content:
                      - type: thinking
                        thinking: ユーザーは一語で挨拶するよう求めているので、"Hi" と答えればよい。
                        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: ツール呼び出しをトリガー（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: リクエストパラメータエラー
          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: 認証エラー
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: authentication_error
                  message: Authentication error
        '402':
          description: クォータ不足
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: billing_error
                  message: Insufficient quota
        '403':
          description: 権限エラー
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: permission_error
                  message: Permission denied
        '404':
          description: モデルまたはリソースが存在しません
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: not_found_error
                  message: Model not found
        '429':
          description: レート制限
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                type: error
                error:
                  type: rate_limit_error
                  message: Rate limited
        '500':
          description: サーバー内部エラー
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '502':
          description: 上流サービスエラー
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '503':
          description: サービス一時利用不可
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreateMessageQuickRequest:
      title: Create Message Quick Request
      type: object
      required:
        - model
        - max_tokens
        - messages
      properties:
        model:
          type: string
          description: >
            呼び出すモデル：


            | モデル ID | 位置づけ |

            |---|---|

            | `glm-5.3` | フラッグシップモデル。複雑なソフトウェアエンジニアリングとエージェントタスクの能力が全面的に向上；1M
            コンテキスト |

            | `glm-5.3-flash` | 軽量マルチモーダルモデル。コストが極めて低く、画像入力にネイティブ対応；1M コンテキスト |

            | `glm-5.2` | 前世代のフラッグシップ。複雑な推論と超長コンテキスト；1M コンテキスト |
          enum:
            - glm-5.3
            - glm-5.3-flash
            - glm-5.2
          default: glm-5.3
          example: glm-5.3
        max_tokens:
          type: integer
          description: >-
            今回の生成における最大トークン数。Anthropic プロトコルでは**必須**です。


            注意：GLM シリーズはデフォルトで思考が有効になっており、思考内容も output
            トークンを消費します。そのため、この値は小さすぎないほうがよく、1024 以上を推奨します。
          minimum: 1
          maximum: 131072
          default: 1024
          example: 1024
        messages:
          type: array
          description: 対話メッセージのリスト。時系列順に並べます。最低 1 件のメッセージが必要です。
          minItems: 1
          items:
            $ref: '#/components/schemas/MessageSimple'
    MessageResponse:
      type: object
      description: Anthropic スタイルのメッセージレスポンス
      properties:
        id:
          type: string
          description: メッセージの一意の ID（形式：`msg_<uuid>`）
        type:
          type: string
          enum:
            - message
          description: レスポンスオブジェクトの種類
        role:
          type: string
          enum:
            - assistant
        model:
          type: string
          description: 実際に使用されたモデル
          example: glm-5.3
        content:
          type: array
          description: |-
            レスポンスのコンテンツブロックのリスト

            **含まれる可能性のある block type**：
            - `thinking`：推論過程（思考が有効な場合、デフォルトで有効）
            - `text`：最終的な回答テキスト
            - `tool_use`：モデルが発起したツール呼び出し
          items:
            $ref: '#/components/schemas/OutputContentBlock'
        stop_reason:
          type: string
          description: |-
            停止理由

            - `end_turn`：自然終了（stop_sequences にヒットした場合もこの値を返します）
            - `max_tokens`：max_tokens の上限に到達
            - `tool_use`：モデルがツール呼び出しをトリガー
          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: >-
                エラーの種類（invalid_request_error / authentication_error /
                billing_error など）
            message:
              type: string
              description: エラーの説明
        request_id:
          type: string
          description: リクエスト追跡 ID
    MessageSimple:
      title: Message
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          description: |-
            メッセージのロール

            - `user`：ユーザー入力
            - `assistant`：モデルの応答（マルチターン対話で付与）

            システムプロンプトは `messages` の中ではなく、トップレベルの `system` フィールドで渡してください。
          example: user
        content:
          type: string
          description: メッセージ内容（プレーンテキスト）
          example: こんにちは、一文で自己紹介してください
    OutputContentBlock:
      type: object
      description: レスポンス内のコンテンツブロック
      properties:
        type:
          type: string
          enum:
            - text
            - thinking
            - tool_use
        text:
          type: string
          description: type=`text` の場合のテキスト
        thinking:
          type: string
          description: type=`thinking` の場合の推論過程テキスト
        signature:
          type: string
          description: type=`thinking` の場合の署名（空文字列になる場合があります）
        id:
          type: string
          description: type=`tool_use` の場合のツール呼び出し ID
        name:
          type: string
          description: type=`tool_use` の場合のツール名
        input:
          type: object
          description: type=`tool_use` の場合にモデルが生成した JSON 入力パラメータ
    AnthropicUsage:
      type: object
      description: Token 使用統計（Anthropic 仕様）
      properties:
        input_tokens:
          type: integer
          description: 入力 token 数（キャッシュに未ヒットの部分）
          example: 18
        output_tokens:
          type: integer
          description: 出力 token 数（thinking を含む）
          example: 101
        cache_creation_input_tokens:
          type: integer
          description: キャッシュ作成の入力トークン数（GLM シリーズでは常に 0）
          example: 0
        cache_read_input_tokens:
          type: integer
          description: キャッシュにヒットした入力 token 数（暗黙的キャッシュにヒットした場合は同じプレフィックスの長さにほぼ等しくなります）
          example: 0
        prompt_tokens_details:
          type: object
          description: 入力トークンの内訳（キャッシュヒット関連のフィールド。GLM シリーズでも返されます）
          properties:
            cached_tokens:
              type: integer
              description: キャッシュにヒットした入力 token 数
              example: 0
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: |-
        ##すべての API は Bearer Token 認証が必要です##

        **API キーの取得：**

        [API キー管理ページ](https://evolink.ai/dashboard/keys)にアクセスして API キーを取得してください

        **リクエストヘッダーに追加：**
        ```
        Authorization: Bearer YOUR_API_KEY
        ```

        **備考**：EvoLink は `/v1/messages` に対して一律で Bearer Token 認証を採用しています。

````