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

# MiniMax-M3.1-Flash - Anthropic 兼容接口

> - 使用 Anthropic Messages 协议调用 MiniMax-M3.1-Flash 模型
- 请求 / 响应结构与 Anthropic API 对齐
- **多模态对话**：`content` 支持文本、图像、视频内容块
- **系统提示词**：通过顶层 `system` 传入
- **思考模式**：始终开启，`output_config.effort` 调节思考深度；思考内容通过 `content[type=thinking]` block 返回
- **流式输出**：SSE 事件流
- **工具调用**：兼容 Anthropic `tool_use` / `tool_result` 流程

**流式事件**：`message_start` → `content_block_start` → `content_block_delta`（`thinking_delta` / `signature_delta` / `text_delta` / `input_json_delta`）→ `content_block_stop` → `message_delta` → `message_stop`，期间可能穿插 `ping`。最终用量以 `message_delta` 事件中的 `usage` 为准。

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


## OpenAPI

````yaml cn/api-manual/language-series/minimax-m3.1-flash/minimax-m3.1-flash-messages.json POST /v1/messages
openapi: 3.1.0
info:
  title: MiniMax-M3.1-Flash Anthropic 兼容接口
  description: >-
    MiniMax-M3.1-Flash 通过 Anthropic Messages 协议调用的完整 API 参考。


    **兼容说明**：

    - 路径：`/v1/messages`（Anthropic 标准路径）

    - 请求 / 响应结构与 Anthropic Messages API 一致

    - 已支持字段：`model` `messages`（必填）`system` `max_tokens` `temperature` `top_p`
    `stream` `thinking` `output_config` `tools` `tool_choice` `metadata`


    **模型能力**：

    - 上下文长度：**1,000,000 tokens**（1M）

    - 最大输出：**524,288 tokens**（512K），推荐 **131,072 tokens**（128K），思考 token 计入其中

    - 思考模式：始终开启，通过 `output_config.effort` 调节思考深度，默认 `max`；思考内容通过
    `content[type=thinking]` block 返回

    - 多模态输入：支持文本、图像、视频内容块

    - 上下文缓存：相同前缀自动命中，命中部分体现在 `usage.cache_read_input_tokens`


    多轮对话时，请原样回传完整 assistant 内容块，包括 `thinking`（含 `signature`）与 `tool_use`。
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://direct.evolink.ai
    description: 生产环境（推荐）
  - url: https://api.evolink.ai
    description: 备用地址
security:
  - bearerAuth: []
tags:
  - name: Messages
    description: Anthropic Messages 协议接口
paths:
  /v1/messages:
    post:
      tags:
        - Messages
      summary: MiniMax-M3.1-Flash Messages 接口（Anthropic 兼容）
      description: >-
        - 使用 Anthropic Messages 协议调用 MiniMax-M3.1-Flash 模型

        - 请求 / 响应结构与 Anthropic API 对齐

        - **多模态对话**：`content` 支持文本、图像、视频内容块

        - **系统提示词**：通过顶层 `system` 传入

        - **思考模式**：始终开启，`output_config.effort` 调节思考深度；思考内容通过
        `content[type=thinking]` block 返回

        - **流式输出**：SSE 事件流

        - **工具调用**：兼容 Anthropic `tool_use` / `tool_result` 流程


        **流式事件**：`message_start` → `content_block_start` →
        `content_block_delta`（`thinking_delta` / `signature_delta` /
        `text_delta` / `input_json_delta`）→ `content_block_stop` →
        `message_delta` → `message_stop`，期间可能穿插 `ping`。最终用量以 `message_delta`
        事件中的 `usage` 为准。
      operationId: createMessageMiniMaxM31Flash
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMessageRequest'
            examples:
              simple:
                summary: 最小可运行请求
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  messages:
                    - role: user
                      content: Hello! How can you help me?
              system_prompt:
                summary: 使用系统提示词
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  system: >-
                    You are a technical editor. Keep your answers clear and
                    concise.
                  messages:
                    - role: user
                      content: >-
                        Describe the benefits of clear technical documentation
                        in three sentences.
              effort:
                summary: 调节思考深度（output_config.effort）
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  output_config:
                    effort: high
                  messages:
                    - role: user
                      content: >-
                        A bat and a ball cost 1.10 in total. The bat costs 1.00
                        more than the ball. How much does the ball cost?
              image_understanding:
                summary: 图像理解（多模态内容块）
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: What is shown in this image?
                        - type: image
                          source:
                            type: url
                            url: https://example.com/image.jpeg
              video_understanding:
                summary: 视频理解（多模态内容块）
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  messages:
                    - role: user
                      content:
                        - type: text
                          text: Summarize this video.
                        - type: video
                          source:
                            type: url
                            url: https://example.com/video.mp4
                            fps: 1
              tool_use:
                summary: 工具调用（Anthropic tool_use 风格）
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  messages:
                    - role: user
                      content: Check the stock for product demo-item-001.
                  tools:
                    - name: get_product_stock
                      description: Get the current stock level for a product.
                      input_schema:
                        type: object
                        properties:
                          product_id:
                            type: string
                            description: Product identifier.
                        required:
                          - product_id
                  tool_choice:
                    type: auto
              streaming:
                summary: 流式输出（SSE）
                value:
                  model: MiniMax-M3.1-Flash
                  max_tokens: 131072
                  stream: true
                  messages:
                    - role: user
                      content: Write a short poem about spring.
      responses:
        '200':
          description: 消息对象
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageResponse'
              examples:
                with_thinking:
                  summary: 包含思考内容（thinking block）
                  value:
                    id: 072514f09a86ce2abb0c5c3930f924fb
                    type: message
                    role: assistant
                    model: MiniMax-M3.1-Flash
                    content:
                      - thinking: Let the ball cost x. Then 2x + 1 = 1.10, so x = 0.05.
                        signature: >-
                          84eddf556420e0cc237f8f50212216543e8add2ddd931c9a271d2a5a95689333
                        type: thinking
                      - text: '0.05'
                        type: text
                    usage:
                      input_tokens: 55
                      output_tokens: 66
                      cache_creation_input_tokens: 0
                      cache_read_input_tokens: 174
                      output_tokens_details:
                        thinking_tokens: 63
                    stop_reason: end_turn
                    base_resp:
                      status_code: 0
                      status_msg: ''
                direct_answer:
                  summary: 直接回答（无思考内容）
                  value:
                    id: 072514d15927960e42b730074205a1c6
                    type: message
                    role: assistant
                    model: MiniMax-M3.1-Flash
                    content:
                      - text: >-
                          Recursion is a technique in which a function calls
                          itself to solve smaller instances of a problem.
                        type: text
                    usage:
                      input_tokens: 23
                      output_tokens: 6
                      cache_creation_input_tokens: 0
                      cache_read_input_tokens: 184
                    stop_reason: end_turn
                    base_resp:
                      status_code: 0
                      status_msg: ''
                tool_use:
                  summary: 触发工具调用（stop_reason=tool_use）
                  value:
                    id: 072514d3fb0f7ce9f7c9fdd22755fffc
                    type: message
                    role: assistant
                    model: MiniMax-M3.1-Flash
                    content:
                      - type: tool_use
                        id: call_function_ih2iv0ggec0p_1
                        name: get_product_stock
                        input:
                          product_id: demo-item-001
                    usage:
                      input_tokens: 283
                      output_tokens: 31
                      cache_creation_input_tokens: 0
                      cache_read_input_tokens: 174
                    stop_reason: tool_use
                    base_resp:
                      status_code: 0
                      status_msg: ''
        '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:
    CreateMessageRequest:
      type: object
      required:
        - model
        - messages
      properties:
        model:
          type: string
          description: 要调用的模型
          enum:
            - MiniMax-M3.1-Flash
          example: MiniMax-M3.1-Flash
        max_tokens:
          type: integer
          description: |-
            生成内容长度上限（Token 数），**包含思考和回答**

            **说明**：
            - 推荐 **131,072**（128K），最大 **524,288**（512K）
            - 取值过小时可能在思考阶段就达到上限，返回 `stop_reason=max_tokens` 且没有 text 内容
          minimum: 1
          maximum: 524288
          example: 131072
        messages:
          type: array
          description: |-
            对话消息列表，按轮次 user / assistant 交替

            **说明**：
            - 至少包含 1 条消息
            - 最后一条消息通常为 `role=user`
          items:
            $ref: '#/components/schemas/InputMessage'
          minItems: 1
        system:
          description: 系统提示词，用于设定 AI 角色与行为。支持字符串或文本内容块数组，通过顶层 `system` 字段传入。
          oneOf:
            - type: string
              example: You are a helpful assistant.
            - type: array
              description: 内容块数组格式的系统提示词
              items:
                type: object
                required:
                  - type
                  - text
                properties:
                  type:
                    type: string
                    enum:
                      - text
                  text:
                    type: string
        temperature:
          type: number
          description: |-
            采样温度

            **说明**：
            - 范围 `[0, 2]`，默认 1
            - 值越高越发散，越低越确定
            - 建议不要同时调整 temperature 与 top_p
          minimum: 0
          maximum: 2
          default: 1
          example: 1
        top_p:
          type: number
          description: |-
            核采样阈值

            **说明**：
            - 范围 `[0, 1]`，默认 0.95
            - 建议不要同时调整 temperature 与 top_p
          minimum: 0
          maximum: 1
          default: 0.95
          example: 0.95
        stream:
          type: boolean
          description: |-
            是否以 SSE 流式返回

            - `true`：Server-Sent Events 流式返回
            - `false`：完整响应后一次性返回（默认）
          default: false
          example: false
        thinking:
          type: object
          description: >-
            思考模式。MiniMax-M3.1-Flash 始终进行思考，仅支持 `adaptive`，可省略。思考内容以
            `type="thinking"` 的 block 返回，按输出 token 计费
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - adaptive
              default: adaptive
        output_config:
          type: object
          description: 输出配置
          properties:
            effort:
              type: string
              description: 思考深度，默认 `max`。较高档位通常会增加思考 token 消耗和响应时间。
              enum:
                - low
                - medium
                - high
                - xhigh
                - max
              default: max
              example: high
        tools:
          type: array
          description: |-
            工具定义列表

            **说明**：
            - 遵循 Anthropic tool 定义规范
            - `input_schema` 使用 JSON Schema 对象
          items:
            $ref: '#/components/schemas/Tool'
        tool_choice:
          type: object
          description: 工具选择策略，仅支持 `auto`（由模型决定是否调用工具）
          required:
            - type
          properties:
            type:
              type: string
              enum:
                - auto
        metadata:
          type: object
          description: 请求元数据
          properties:
            user_id:
              type: string
              description: 代表终端用户的唯一标识符，可用于按用户维度做监控与滥用检测（建议使用散列后的 ID）
    MessageResponse:
      type: object
      description: Anthropic 风格的消息响应
      properties:
        id:
          type: string
          description: 消息唯一 ID
        type:
          type: string
          enum:
            - message
          description: 响应对象类型
        role:
          type: string
          enum:
            - assistant
        model:
          type: string
          description: 实际使用的模型
          example: MiniMax-M3.1-Flash
        content:
          type: array
          description: |-
            响应内容块列表

            **可能包含的 block type**：
            - `thinking`：思考过程（简单问题可能不产生）
            - `text`：最终回答文本
            - `tool_use`：模型发起的工具调用
          items:
            $ref: '#/components/schemas/OutputContentBlock'
        stop_reason:
          type: string
          description: |-
            停止原因

            - `end_turn`：自然结束
            - `max_tokens`：达到 max_tokens 上限
            - `tool_use`：模型触发工具调用
          enum:
            - end_turn
            - max_tokens
            - tool_use
        usage:
          $ref: '#/components/schemas/AnthropicUsage'
        base_resp:
          type: object
          description: 状态码和错误详情
          properties:
            status_code:
              type: integer
              description: 状态码，`0` 表示成功
            status_msg:
              type: string
              description: 错误详情
    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
    InputMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
            - assistant
          description: |-
            消息发送方角色，user / assistant 交替

            - `user`：用户消息（也用于回传 `tool_result` block）
            - `assistant`：助手历史回复（可含 `text` / `thinking` / `tool_use` blocks）

            系统提示通过顶层 `system` 字段传入。
        content:
          description: >-
            消息内容


            **说明**：

            - 纯文本时直接传字符串

            - 结构化时传 content block 数组（`text` / `image` / `video` / `tool_use` /
            `tool_result` / `thinking`）
          oneOf:
            - type: string
            - type: array
              items:
                $ref: '#/components/schemas/ContentBlock'
    Tool:
      type: object
      required:
        - name
        - input_schema
      properties:
        name:
          type: string
          description: |-
            工具名称

            **说明**：
            - 只允许 `a-zA-Z0-9_-`
            - 最大 64 字符
        description:
          type: string
          description: 工具功能描述，供模型判断何时调用
        input_schema:
          type: object
          description: |-
            工具入参的 JSON Schema 对象

            **说明**：
            - `type` 必须为 `object`
            - 应声明 `properties` 与 `required`
    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 数（不含 `cache_read_input_tokens`）
          example: 55
        output_tokens:
          type: integer
          description: 输出 token 数（含 thinking）
          example: 66
        cache_creation_input_tokens:
          type: integer
          description: 缓存创建的输入 token 数，自动缓存下为 0
          example: 0
        cache_read_input_tokens:
          type: integer
          description: >-
            命中缓存的输入 token 数，按缓存命中价计费。完整输入 = `input_tokens +
            cache_read_input_tokens`
          example: 174
        output_tokens_details:
          type: object
          description: 输出 token 详细分项
          properties:
            thinking_tokens:
              type: integer
              description: 思考产生的 token 数（已计入 `output_tokens`）
              example: 63
    ContentBlock:
      type: object
      description: |-
        消息内容块

        **支持 type**：
        - `text`：文本内容
        - `image`：图片输入（URL 或 base64，JPEG / PNG / GIF / WEBP）
        - `video`：视频输入（URL、base64 或 `mm_file://{file_id}`，MP4 / AVI / MOV / MKV）
        - `tool_use`：回传上一轮 assistant 工具调用
        - `tool_result`：工具执行结果
        - `thinking`：回传上一轮 assistant 思考内容（含 `signature`）
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - text
            - image
            - video
            - tool_use
            - tool_result
            - thinking
        text:
          type: string
          description: 当 type=`text` 时的文本内容
        source:
          $ref: '#/components/schemas/MediaSource'
          description: 图片或视频来源，type=`image` 或 type=`video` 时使用
        id:
          type: string
          description: 工具调用 ID（tool_use 时必填）
        name:
          type: string
          description: 工具名（tool_use 时必填）
        input:
          type: object
          description: 工具入参（tool_use 时，JSON 对象）
        tool_use_id:
          type: string
          description: 对应的工具调用 ID（tool_result 时必填，回填到 tool_use.id）
        content:
          description: 工具执行结果（tool_result），字符串或 content block 数组
          oneOf:
            - type: string
            - type: array
              items:
                type: object
        thinking:
          type: string
          description: 历史助手消息中的思考内容（`type=thinking` 时使用）
        signature:
          type: string
          description: 思考内容签名，多轮对话时需原样回传
    MediaSource:
      type: object
      description: >-
        图片或视频内容块的媒体来源


        - 图片支持 JPEG / PNG / GIF / WEBP，单张最大 10 MB

        - 视频支持 MP4 / AVI / MOV / MKV，URL / Base64 最大 50 MB；更大的视频通过
        `mm_file://{file_id}` 文件引用传入

        - 请求体最大 64 MB
      required:
        - type
      properties:
        type:
          type: string
          enum:
            - base64
            - url
          description: 媒体来源类型
        media_type:
          type: string
          description: base64 输入时必填，例如 `image/png` 或 `video/mp4`
        data:
          type: string
          description: base64 编码后的媒体字节
        url:
          type: string
          description: 公网 URL；视频还可使用形如 `mm_file://{file_id}` 的文件引用
        detail:
          type: string
          enum:
            - low
            - default
            - high
          default: default
          description: 理解精细度，默认 default。分辨率越高 token 消耗越多
        fps:
          type: number
          minimum: 0.2
          maximum: 5
          default: 1
          description: 视频抽帧频率，默认 1，范围 [0.2, 5]。较高的抽帧频率有利于捕捉画面变化，通常也会增加 token 消耗。
        max_long_side_pixel:
          type: integer
          minimum: 1
          description: 图片或视频帧最长边像素约束
  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
        ```

        **备注**：EvoLink 对 `/v1/messages` 统一采用 Bearer Token 鉴权。

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.