{
  "openapi": "3.1.0",
  "info": {
    "title": "MiniMax Text API Anthropic",
    "description": "MiniMax 文本生成 API，支持对话补全与流式输出。\n\n> ⚡ **`MiniMax-M3.1-Flash-Preview` 亮点** —— **1M 超长上下文**、**多模态**、**思考深度可调**。\n",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.minimax.cn"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyAuth": []
    }
  ],
  "paths": {
    "/anthropic/v1/messages": {
      "post": {
        "summary": "Text Generation Anthropic",
        "operationId": "chatCompletionAnthropic",
        "tags": [
          "Text Generation"
        ],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "description": "请求体的媒介类型，请设置为 `application/json`，确保请求数据的格式为 JSON",
            "schema": {
              "type": "string",
              "enum": [
                "application/json"
              ],
              "default": "application/json"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMessageReq"
              },
              "examples": {
                "深度思考": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash-Preview",
                    "thinking": {
                      "type": "adaptive"
                    },
                    "messages": [
                      {
                        "role": "user",
                        "content": "9.11 和 9.9 哪个更大？"
                      }
                    ],
                    "max_tokens": 4096,
                    "output_config": {
                      "effort": "max"
                    }
                  }
                },
                "图片理解": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash-Preview",
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "text",
                            "text": "这张图片的内容是什么？"
                          },
                          {
                            "type": "image",
                            "source": {
                              "type": "url",
                              "url": "https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg"
                            }
                          }
                        ]
                      }
                    ],
                    "max_tokens": 4096,
                    "thinking": {
                      "type": "adaptive"
                    },
                    "output_config": {
                      "effort": "max"
                    }
                  }
                },
                "视频理解": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash-Preview",
                    "thinking": {
                      "type": "adaptive"
                    },
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "text",
                            "text": "这个视频里发生了什么？"
                          },
                          {
                            "type": "video",
                            "source": {
                              "type": "url",
                              "url": "https://filecdn.minimax.chat/public/ee8c1648-21f1-41b7-8397-65022d22ffe5.mp4"
                            }
                          }
                        ]
                      }
                    ],
                    "max_tokens": 4096,
                    "output_config": {
                      "effort": "max"
                    }
                  }
                },
                "流式": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash-Preview",
                    "messages": [
                      {
                        "role": "user",
                        "content": [
                          {
                            "type": "text",
                            "text": "这张图片的内容是什么？"
                          },
                          {
                            "type": "image",
                            "source": {
                              "type": "url",
                              "url": "https://filecdn.minimax.chat/public/fe9d04da-f60e-444d-a2e0-18ae743add33.jpeg"
                            }
                          }
                        ]
                      }
                    ],
                    "stream": true,
                    "max_tokens": 4096,
                    "thinking": {
                      "type": "adaptive"
                    },
                    "output_config": {
                      "effort": "max"
                    }
                  }
                },
                "工具调用": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash-Preview",
                    "messages": [
                      {
                        "role": "user",
                        "content": "旧金山现在天气怎么样？"
                      }
                    ],
                    "max_tokens": 4096,
                    "tools": [
                      {
                        "name": "get_weather",
                        "description": "Get the current weather for a given location.",
                        "input_schema": {
                          "type": "object",
                          "properties": {
                            "location": {
                              "type": "string",
                              "description": "The city and state/country, e.g. San Francisco, US"
                            }
                          },
                          "required": [
                            "location"
                          ]
                        }
                      }
                    ],
                    "tool_choice": {
                      "type": "auto"
                    },
                    "output_config": {
                      "effort": "max"
                    }
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CreateMessageResp"
                },
                "examples": {
                  "深度思考": {
                    "value": {
                      "id": "066b367547c2650d17dc215f503da551",
                      "type": "message",
                      "role": "assistant",
                      "model": "MiniMax-M3.1-Flash-Preview",
                      "content": [
                        {
                          "thinking": "The user is asking which is larger: 9.11 or 9.9.\n\nComparing 9.11 and 9.9:\n9.9 = 9.90\n9.11 = 9.11\n\n9.90 > 9.11, so 9.9 is larger.",
                          "signature": "7564f4e0e54b5c08b380d0b800aeb5463ea050e546cec7722e08ef6e912f6c67",
                          "type": "thinking"
                        },
                        {
                          "text": "**9.9 更大。**\n\n比较方法很简单：将两个数的小数位数对齐后比较：\n\n- 9.11 = 9.**11**\n- 9.9 = 9.**90**\n\n因为 90 > 11，所以 **9.9 > 9.11**。\n\n这是一个常见的思维陷阱——虽然 11 看起来比 9 大，但在比较小数时，应该先比较整数部分（都是 9），然后再比较小数部分，而小数部分需要**补齐位数**后再比较。",
                          "type": "text"
                        }
                      ],
                      "usage": {
                        "input_tokens": 13,
                        "output_tokens": 172,
                        "cache_creation_input_tokens": 0,
                        "cache_read_input_tokens": 157
                      },
                      "stop_reason": "end_turn"
                    }
                  },
                  "图片理解": {
                    "value": {
                      "id": "066a381bdc3c0ded310e27c9a46d16e7",
                      "type": "message",
                      "role": "assistant",
                      "model": "MiniMax-M3.1-Flash-Preview",
                      "content": [
                        {
                          "thinking": "The user is asking in Chinese what the content of the image is. I should describe the image in Chinese.",
                          "signature": "6b19dfedcc8d3e065eb0ebe4262efd4a69e3e73ad69eeb7e5e629e552c40f969",
                          "type": "thinking"
                        },
                        {
                          "text": "这张图片是一张温馨的儿童肖像照片，内容如下：\n\n**主体**：一个大约4-6岁的小女孩，有着棕色的卷曲长发和齐刘海，扎着蓬松的发型。她有一双大大的浅棕色（琥珀色）眼睛，长长的睫毛，粉嫩的嘴唇微微上扬，露出甜美自然的微笑。\n\n**服饰**：她穿着一件米白色或浅奶油色的连衣裙，领口和肩部有精致的蕾丝花边装饰，袖子是蓬松的荷叶边设计，整体风格显得优雅可爱。\n\n**光影与背景**：照片采用了柔和的暖色调光线，背景是朦胧的米灰色/暖灰色，营造出温馨柔和的氛围。光线从侧面打来，突出了她脸部的轮廓和头发的质感。\n\n**整体风格**：这是一张高质量的人像摄影作品，采用了浅景深的虚化效果（背景模糊），突出了小女孩纯真可爱的形象，画面充满童真与温暖感。",
                          "type": "text"
                        }
                      ],
                      "usage": {
                        "input_tokens": 1209,
                        "output_tokens": 211,
                        "cache_creation_input_tokens": 0,
                        "cache_read_input_tokens": 156
                      },
                      "stop_reason": "end_turn"
                    }
                  },
                  "视频理解": {
                    "value": {
                      "id": "066b4573467fa2bb299cee687b68873d",
                      "type": "message",
                      "role": "assistant",
                      "model": "MiniMax-M3.1-Flash-Preview",
                      "content": [
                        {
                          "thinking": "The user is asking in Chinese: \"What happened in this video?\"\n\nI need to describe the events in the video clip provided.\n\n1.  **Analyze the initial state (0.0s - 0.2s):** A spotted cat, resembling a Bengal cat, is walking confidently on a springboard, which looks like a diving board. The background shows an Olympic setting (\"Lausanne 2022\" and the Olympic rings are visible). There's a crowd watching in the background. The cat is moving towards the end of the board.\n2.  **Observe the action (0.2s - 0.4s):** The cat reaches the end of the springboard and leaps off.\n3.  **Follow the trajectory (0.4s - 0.5s):** The cat is in mid-air, flying over a swimming pool. It looks like it's doing a dive.\n4.  **Analyze the final state (0.5s - 0.6s):** The cat splashes into the blue water of the swimming pool, creating a white splash. A person standing by the side of the pool appears to be reacting or clapping.\n\n**Synthesize the description:**\n- Start with the subject: A cat.\n- Describe its initial action: Walking on a diving board (springboard).\n- Describe the setting: It looks like an Olympic swimming event (Lausanne 2022).\n- Describe the main event: The cat jumps off the diving board into the air.\n- Describe the conclusion: The cat lands in the swimming pool, making a splash.\n\n**Translate to Chinese (as requested implicitly by the prompt language, but I should respond in the language the user used. The user asked in Chinese, so I will respond in Chinese. Wait, let me double-check standard practices. Usually, I should answer in the same language as the prompt. Prompt is Chinese. So, answer in Chinese.)\n\n**Drafting the Chinese response:**\n- 视频里，一只猫正在走路。\n- 它走到跳板的尽头。\n- 然后它从跳板上跳了下去。\n- 它在空中飞了一会儿。\n- 最后，它一头扎进了游泳池里，溅起了一片水花。\n- 背景看起来像是在洛桑2022年奥运会。\n\nLet's refine it into a concise and accurate description.\n\"视频显示，一只猫在跳水板上行走，然后从跳水板上跳下，扎进游泳池里。\" (The video shows a cat walking on a diving board, then jumping off it and plunging into a swimming pool.)\n\nLet's add a bit more detail based on the visual evidence.\n\"在洛桑2022年奥运会的背景下，一只猫在跳板上走到尽头，然后纵身一跃，跳入泳池中。\" (Against the backdrop of the Lausanne 2022 Olympics, a cat walks to the end of a diving board, then leaps and jumps into a swimming pool.)\n\nLet's stick to a simple, direct description of the main action.\n\"一只猫在跳板上行走，随后从跳板上跳下，扎进了身后的游泳池中。\" (A cat walks on a diving board, then jumps off the board and plunges into the swimming pool behind it.)\n\nThis is a good, concise summary of the key events. It covers the initial state, the action, and the final state.",
                          "signature": "3ebe06a965f7edbb379552ee8f6485100f473eb42f12fb3541d952d5f5908d46",
                          "type": "thinking"
                        },
                        {
                          "text": "视频显示，一只猫在跳板上行走，随后从跳板上跳下，扎进了身后的游泳池中。",
                          "type": "text"
                        }
                      ],
                      "usage": {
                        "input_tokens": 349,
                        "output_tokens": 686,
                        "cache_creation_input_tokens": 0,
                        "cache_read_input_tokens": 1894
                      },
                      "stop_reason": "end_turn"
                    }
                  },
                  "流式": {
                    "value": [
                      {
                        "type": "message_start",
                        "message": {
                          "id": "066a38a98a4ffbf5554a468fe0cbedf6",
                          "type": "message",
                          "role": "assistant",
                          "content": [],
                          "model": "MiniMax-M3.1-Flash-Preview",
                          "stop_reason": null,
                          "stop_sequence": null,
                          "usage": {
                            "input_tokens": 0,
                            "output_tokens": 0,
                            "cache_creation_input_tokens": 0,
                            "cache_read_input_tokens": 1365
                          },
                          "service_tier": "standard"
                        }
                      },
                      {
                        "type": "ping"
                      },
                      {
                        "type": "content_block_start",
                        "index": 0,
                        "content_block": {
                          "type": "thinking",
                          "thinking": ""
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": "The user"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " is asking in Chinese what the content of this image is. Let me describe it in Chinese.\n\nThe"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " image shows a close-up portrait of a young girl with curly/wavy brown hair and bangs."
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " She has brown eyes and is smiling slightly at the camera. She's wearing a cream/iv"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": "ory colored dress with lace details and ruffles. The lighting is soft and warm, creating a classic"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " portrait photography feel. The background is a neutral olive/grayish color, blurred to keep focus"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " on the subject."
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "signature_delta",
                          "signature": "6deea14a039646c64cff2cdc13db8e1aa093c3f7334bfd4941ee1eee8663b214"
                        }
                      },
                      {
                        "type": "content_block_stop",
                        "index": 0
                      },
                      {
                        "type": "content_block_start",
                        "index": 1,
                        "content_block": {
                          "type": "text",
                          "text": ""
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "这张图片是一张温馨的儿童人像摄影作品，主要内容如下"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "：\n\n**人物：**\n- 一个大约5-7岁的小女孩\n- 有着卷曲蓬"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "松的棕色头发，留着刘海\n- 有着明亮的棕色大眼睛\n- 微微"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "带着甜美的微笑看向镜头\n\n**服装：**\n- 身穿一件米白色/象牙色的"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "连衣裙\n- 衣领和肩部有精致的蕾丝花边和褶"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "皱装饰\n\n**拍摄风格：**\n- 经典的近距离肖像构图\n- 柔和的暖色调"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "光线，营造出温馨的氛围\n- 背景是模糊的橄榄灰色调，使人物更加突出"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "\n- 整体呈现出专业的人像摄影质感，光影处理细腻\n\n这是一张"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "很有艺术感的儿童写真照，捕捉到了小女孩天真可爱的瞬间。"
                        }
                      },
                      {
                        "type": "content_block_stop",
                        "index": 1
                      },
                      {
                        "type": "message_delta",
                        "delta": {
                          "stop_reason": "end_turn"
                        },
                        "usage": {
                          "input_tokens": 1251,
                          "output_tokens": 264,
                          "cache_creation_input_tokens": 0,
                          "cache_read_input_tokens": 114
                        }
                      },
                      {
                        "type": "message_stop"
                      }
                    ]
                  },
                  "工具调用": {
                    "value": {
                      "id": "066b13de1224099141792cd806ed4f56",
                      "type": "message",
                      "role": "assistant",
                      "model": "MiniMax-M3.1-Flash-Preview",
                      "content": [
                        {
                          "thinking": "The user is asking about the current weather in San Francisco. I should use the get_weather tool to fetch this information. The location parameter requires city and state/country format, so \"San Francisco, US\" would be appropriate.",
                          "signature": "ca8010ef1c5606561a17158c090bd20f33a8a8ac5f3b6cfb4326408395cbff39",
                          "type": "thinking"
                        },
                        {
                          "type": "tool_use",
                          "id": "call_function_debp7sfnk20c_1",
                          "name": "get_weather",
                          "input": {
                            "location": "San Francisco, US"
                          }
                        }
                      ],
                      "usage": {
                        "input_tokens": 14,
                        "output_tokens": 79,
                        "cache_creation_input_tokens": 0,
                        "cache_read_input_tokens": 397
                      },
                      "stop_reason": "tool_use"
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/StreamEvent"
                },
                "examples": {
                  "流式": {
                    "value": [
                      {
                        "type": "message_start",
                        "message": {
                          "id": "066a38a98a4ffbf5554a468fe0cbedf6",
                          "type": "message",
                          "role": "assistant",
                          "content": [],
                          "model": "MiniMax-M3.1-Flash-Preview",
                          "stop_reason": null,
                          "stop_sequence": null,
                          "usage": {
                            "input_tokens": 0,
                            "output_tokens": 0,
                            "cache_creation_input_tokens": 0,
                            "cache_read_input_tokens": 1365
                          },
                          "service_tier": "standard"
                        }
                      },
                      {
                        "type": "ping"
                      },
                      {
                        "type": "content_block_start",
                        "index": 0,
                        "content_block": {
                          "type": "thinking",
                          "thinking": ""
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": "The user"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " is asking in Chinese what the content of this image is. Let me describe it in Chinese.\n\nThe"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " image shows a close-up portrait of a young girl with curly/wavy brown hair and bangs."
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " She has brown eyes and is smiling slightly at the camera. She's wearing a cream/iv"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": "ory colored dress with lace details and ruffles. The lighting is soft and warm, creating a classic"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " portrait photography feel. The background is a neutral olive/grayish color, blurred to keep focus"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "thinking_delta",
                          "thinking": " on the subject."
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 0,
                        "delta": {
                          "type": "signature_delta",
                          "signature": "6deea14a039646c64cff2cdc13db8e1aa093c3f7334bfd4941ee1eee8663b214"
                        }
                      },
                      {
                        "type": "content_block_stop",
                        "index": 0
                      },
                      {
                        "type": "content_block_start",
                        "index": 1,
                        "content_block": {
                          "type": "text",
                          "text": ""
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "这张图片是一张温馨的儿童人像摄影作品，主要内容如下"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "：\n\n**人物：**\n- 一个大约5-7岁的小女孩\n- 有着卷曲蓬"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "松的棕色头发，留着刘海\n- 有着明亮的棕色大眼睛\n- 微微"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "带着甜美的微笑看向镜头\n\n**服装：**\n- 身穿一件米白色/象牙色的"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "连衣裙\n- 衣领和肩部有精致的蕾丝花边和褶"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "皱装饰\n\n**拍摄风格：**\n- 经典的近距离肖像构图\n- 柔和的暖色调"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "光线，营造出温馨的氛围\n- 背景是模糊的橄榄灰色调，使人物更加突出"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "\n- 整体呈现出专业的人像摄影质感，光影处理细腻\n\n这是一张"
                        }
                      },
                      {
                        "type": "content_block_delta",
                        "index": 1,
                        "delta": {
                          "type": "text_delta",
                          "text": "很有艺术感的儿童写真照，捕捉到了小女孩天真可爱的瞬间。"
                        }
                      },
                      {
                        "type": "content_block_stop",
                        "index": 1
                      },
                      {
                        "type": "message_delta",
                        "delta": {
                          "stop_reason": "end_turn"
                        },
                        "usage": {
                          "input_tokens": 1251,
                          "output_tokens": 264,
                          "cache_creation_input_tokens": 0,
                          "cache_read_input_tokens": 114
                        }
                      },
                      {
                        "type": "message_stop"
                      }
                    ]
                  }
                }
              }
            }
          },
              "400": {
                "description": "请求参数非法（必填缺失、type 不在白名单、tool_use.input 非 JSON 对象等）",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "invalid_request_error",
                        "message": "messages.0.content.1: unsupported content type 'foo'"
                      }
                    }
                  }
                }
              },
              "401": {
                "description": "API Key 缺失/无效",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "authentication_error",
                        "message": "API Key 缺失/无效"
                      }
                    }
                  }
                }
              },
              "403": {
                "description": "无权访问该模型或该路径",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "permission_error",
                        "message": "无权访问该模型或该路径"
                      }
                    }
                  }
                }
              },
              "404": {
                "description": "模型不存在",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "not_found_error",
                        "message": "模型不存在"
                      }
                    }
                  }
                }
              },
              "413": {
                "description": "请求体超过 64MB，或多模态文件超出大小限制",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "request_too_large",
                        "message": "请求体超过 64MB，或多模态文件超出大小限制"
                      }
                    }
                  }
                }
              },
              "429": {
                "description": "触发 RPM/TPM/连接数 等限流",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "rate_limit_error",
                        "message": "触发 RPM/TPM/连接数 等限流"
                      }
                    }
                  }
                }
              },
              "500": {
                "description": "服务端内部错误",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "api_error",
                        "message": "服务端内部错误"
                      }
                    }
                  }
                }
              },
              "529": {
                "description": "上游模型过载，可重试",
                "content": {
                  "application/json": {
                    "schema": {
                      "$ref": "#/components/schemas/ErrorResponse"
                    },
                    "example": {
                      "type": "error",
                      "request_id": "req_xxxxxxxx",
                      "error": {
                        "type": "overloaded_error",
                        "message": "上游模型过载，可重试"
                      }
                    }
                  }
                }
              }
        }
      }
    },
    "/anthropic/v1/messages/count_tokens": {
      "post": {
        "summary": "Anthropic Token 计数",
        "operationId": "countTokensAnthropic",
        "tags": [
          "Text Generation"
        ],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "description": "请求体的媒介类型，请设置为 `application/json`，确保请求数据的格式为 JSON",
            "schema": {
              "type": "string",
              "enum": [
                "application/json"
              ],
              "default": "application/json"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateMessageReq"
              },
              "examples": {
                "标准": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash-Preview",
                    "messages": [
                      {
                        "role": "user",
                        "content": "Hello"
                      }
                    ]
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "返回本次请求的输入 token 用量，不生成模型输出。",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountTokensResp"
                },
                "examples": {
                  "标准": {
                    "value": {
                      "usage": {
                        "input_tokens": 3,
                        "cache_creation_input_tokens": 0,
                        "cache_read_input_tokens": 0
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateMessageReq": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "模型 ID。`MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 是多模态模型，原生支持文本、图片和视频输入，并兼容工具调用与 thinking 内容块；`MiniMax-M3.1-Flash-Preview` 还会强制开启 thinking，并支持通过 `output_config.effort` 调节思考深度。M2.7、M2.5、M2.1 和 M2 系列仅支持文本与工具调用，不支持图片和视频输入。",
            "enum": [
              "MiniMax-M3.1-Flash-Preview",
              "MiniMax-M3",
              "MiniMax-M2.7",
              "MiniMax-M2.7-highspeed",
              "MiniMax-M2.5",
              "MiniMax-M2.5-highspeed",
              "MiniMax-M2.1",
              "MiniMax-M2.1-highspeed",
              "MiniMax-M2"
            ]
          },
          "service_tier": {
            "type": "string",
            "description": "请求准入服务层级。支持的取值为 `standard` 和 `priority`。省略时默认使用 `standard`。`priority` 的[价格](https://platform.minimax.cn/docs/pricing/overview#models/text)为 `standard` 的 1.5 倍，并会确保请求获得优先准入，使其排在其他请求之前处理，从而带来更快响应并减少失败。",
            "enum": [
              "standard",
              "priority"
            ],
            "default": "standard"
          },
          "system": {
            "description": "设置模型角色与行为。",
            "oneOf": [
              {
                "type": "string",
                "description": "纯文本系统提示词"
              },
              {
                "type": "array",
                "description": "内容块数组格式的系统提示词。text 块可携带 cache_control。",
                "items": {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": [
                        "text"
                      ],
                      "description": "内容块类型"
                    },
                    "text": {
                      "type": "string",
                      "description": "文本内容"
                    },
                    "cache_control": {
                      "$ref": "#/components/schemas/CacheControl"
                    }
                  },
                  "required": [
                    "type",
                    "text"
                  ]
                }
              }
            ]
          },
          "messages": {
            "type": "array",
            "description": "对话历史。`MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持文本、图片、视频、工具调用、工具结果和 thinking 内容块。M2.7、M2.5、M2.1 和 M2 系列仅支持文本与工具调用相关内容块，不支持图片和视频输入。",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "stream": {
            "type": "boolean",
            "description": "是否使用流式传输，默认为 `false`。设置为 `true` 后，响应将分批返回",
            "default": false
          },
          "max_tokens": {
            "type": "integer",
            "format": "int64",
            "description": "指定生成内容长度的上限（Token 数）。MiniMax-M3.1-Flash-Preview 和 MiniMax-M3 推荐值为 131072（128K），上限为 524288（512K）；其他模型推荐值为 65536（64K），上限为 204800（200K）。超过上限的内容会被截断。如果生成因 `length` 原因中断，请尝试调高此值",
            "minimum": 1
          },
          "temperature": {
            "type": "number",
            "format": "double",
            "description": "温度系数，影响输出随机性，取值范围 [0, 2]，默认值为 1。值越高，输出越随机；值越低，输出越确定。",
            "minimum": 0,
            "maximum": 2,
            "default": 1
          },
          "top_p": {
            "type": "number",
            "format": "double",
            "description": "核采样参数，取值范围 [0, 1]。MiniMax-M3.1-Flash-Preview 和 MiniMax-M3 默认值为 0.95，M2.x 系列模型默认值为 0.9。",
            "minimum": 0,
            "maximum": 1,
            "default": 0.95
          },
          "tools": {
            "type": "array",
            "description": "Anthropic 兼容工具调用的工具定义。",
            "items": {
              "$ref": "#/components/schemas/Tool"
            }
          },
          "tool_choice": {
            "$ref": "#/components/schemas/ToolChoice"
          },
          "thinking": {
            "type": "object",
            "description": "控制 thinking 行为。默认值随模型不同，因此未在 schema 层声明统一默认值。\n- `MiniMax-M3.1-Flash-Preview`：强制开启 thinking。若传入 `type` 只能为 `adaptive`；传入 `disabled` 会返回 HTTP 400。如需调节思考深度，请使用 `output_config.effort`。\n- `MiniMax-M3`：省略 `thinking` 时默认关闭；传入 `adaptive` 可开启并返回 thinking 块。\n- M2.x 模型：thinking 无法关闭，传入 `disabled` 会被接收但不生效。",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "disabled",
                  "adaptive"
                ],
                "description": "thinking 控制类型。\n- `disabled`：关闭 `MiniMax-M3` 的 thinking 输出。`MiniMax-M3.1-Flash-Preview` 传入该值会返回 HTTP 400；M2.x 模型会接收但不生效。\n- `adaptive`：开启 thinking 输出并返回 thinking 块。这是 `MiniMax-M3.1-Flash-Preview` 唯一接受的取值。"
              }
            },
            "required": []
          },
          "output_config": {
            "type": "object",
            "description": "输出配置。通过 `effort` 调节 `MiniMax-M3.1-Flash-Preview` 的思考深度。",
            "properties": {
              "effort": {
                "type": "string",
                "description": "`MiniMax-M3.1-Flash-Preview` 的思考深度档位，可取 `low`、`medium`、`high`、`xhigh`、`max`；省略时默认为 `max`。其他模型会忽略该字段。`MiniMax-M3.1-Flash-Preview` 不支持 `none`，传入会返回 HTTP 400。",
                "enum": [
                  "low",
                  "medium",
                  "high",
                  "xhigh",
                  "max"
                ]
              }
            },
            "required": []
          },
          "metadata": {
            "type": "object",
            "description": "请求元信息。建议对 to-C 业务传入 user_id，便于按终端用户聚合限流和计费分析。",
            "properties": {
              "user_id": {
                "type": "string",
                "description": "终端用户 ID。"
              }
            }
          }
        }
      },
      "CreateMessageResp": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "本次响应的唯一 ID"
          },
          "type": {
            "type": "string",
            "description": "对象类型，固定为 `message`",
            "enum": [
              "message"
            ]
          },
          "role": {
            "type": "string",
            "description": "角色，固定为 `assistant`",
            "enum": [
              "assistant"
            ]
          },
          "model": {
            "type": "string",
            "description": "本次请求使用的模型 ID"
          },
          "content": {
            "type": "array",
            "description": "响应内容块列表",
            "items": {
              "$ref": "#/components/schemas/ResponseContentBlock"
            }
          },
          "stop_reason": {
            "type": "string",
            "description": "模型停止生成的原因：\n- end_turn：模型自然结束\n- max_tokens：达到 max_tokens 限制\n- tool_use：模型请求工具调用",
            "enum": [
              "end_turn",
              "max_tokens",
              "tool_use"
            ]
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant",
              "user_system",
              "group",
              "sample_message_user",
              "sample_message_ai"
            ],
            "description": "消息发送方角色。`MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 使用 user / assistant 交替消息。"
          },
          "content": {
            "description": "消息内容。`MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持文本、图片、视频、工具调用、工具结果和 thinking 内容块。",
            "oneOf": [
              {
                "type": "string",
                "description": "纯文本消息"
              },
              {
                "type": "array",
                "description": "消息内容。`MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持文本、图片、视频、工具调用、工具结果和 thinking 内容块。",
                "items": {
                  "$ref": "#/components/schemas/RequestContentBlock"
                }
              }
            ]
          }
        }
      },
      "RequestContentBlock": {
        "type": "object",
        "description": "请求消息中可用的内容块。text 与工具相关块所有模型均支持；image 与 video 块仅 `MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持。thinking 仅在多轮对话中将上一轮 assistant 输出原样回带时使用。",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "内容块类型：\n- text：文本内容\n- image：图片输入，仅 `MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持\n- video：视频输入，仅 `MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持\n- tool_use：回带上一轮的 assistant 工具调用\n- tool_result：工具执行结果\n- thinking：回带上一轮的 assistant 思考内容\n- mid_conv_system：对话中途插入的系统指令",
            "enum": [
              "text",
              "image",
              "video",
              "tool_use",
              "tool_result",
              "thinking",
              "mid_conv_system"
            ]
          },
          "text": {
            "type": "string",
            "description": "文本内容，type=text 时使用。"
          },
          "source": {
            "$ref": "#/components/schemas/MediaSource",
            "description": "图片或视频来源，type=image 或 type=video 时使用，仅 `MiniMax-M3.1-Flash-Preview` 和 `MiniMax-M3` 支持。"
          },
          "id": {
            "type": "string",
            "description": "回带 type=tool_use 时使用的工具调用 ID。"
          },
          "name": {
            "type": "string",
            "description": "回带 type=tool_use 时使用的工具名称。"
          },
          "input": {
            "type": "object",
            "description": "回带 type=tool_use 时使用的工具输入。"
          },
          "tool_use_id": {
            "type": "string",
            "description": "对应 tool_use 块的 ID，type=tool_result 时使用。"
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/RequestContentBlock"
                }
              }
            ],
            "description": "工具执行结果，可为字符串或 text/image 内容块数组。"
          },
          "thinking": {
            "type": "string",
            "description": "回带的 assistant 思考过程内容，type=thinking 时使用。"
          },
          "signature": {
            "type": "string",
            "description": "回带的 thinking 内容签名，多轮续写时需要原样回带。"
          },
          "cache_control": {
            "$ref": "#/components/schemas/CacheControl"
          }
        }
      },
      "ResponseContentBlock": {
        "type": "object",
        "description": "响应消息中的内容块。模型输出 text、tool_use（调用工具时），以及 thinking（开启深度思考时）。响应中不会出现 image、video、tool_result 或 mid_conv_system 块。",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "内容块类型：\n- text：文本内容\n- tool_use：模型工具调用\n- thinking：模型思考过程",
            "enum": [
              "text",
              "tool_use",
              "thinking"
            ]
          },
          "text": {
            "type": "string",
            "description": "文本内容，type=text 时使用。"
          },
          "id": {
            "type": "string",
            "description": "工具调用 ID，type=tool_use 时返回。"
          },
          "name": {
            "type": "string",
            "description": "工具名称，type=tool_use 时返回。"
          },
          "input": {
            "type": "object",
            "description": "工具输入参数，type=tool_use 时返回。"
          },
          "thinking": {
            "type": "string",
            "description": "模型思考过程内容，type=thinking 时使用。"
          },
          "signature": {
            "type": "string",
            "description": "thinking 内容签名，多轮续写时需要原样回带。"
          }
        }
      },
      "Usage": {
        "type": "object",
        "description": "本次请求的 token 用量，包含适用时的 prompt cache 用量。",
        "properties": {
          "input_tokens": {
            "type": "integer",
            "description": "输入消耗的 Token 数"
          },
          "output_tokens": {
            "type": "integer",
            "description": "输出消耗的 Token 数"
          },
          "cache_creation_input_tokens": {
            "type": "integer",
            "description": "创建 prompt cache 的输入 token 数。"
          },
          "cache_read_input_tokens": {
            "type": "integer",
            "description": "命中 prompt cache 的输入 token 数。"
          }
        }
      },
      "StreamEvent": {
        "type": "object",
        "description": "",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "description": "事件类型：\n- `message_start`: 消息开始，包含完整的消息元数据\n- `ping`: 心跳事件\n- `content_block_start`: 内容块开始\n- `content_block_delta`: 内容块增量更新\n- `content_block_stop`: 内容块结束\n- `message_delta`: 消息级别的增量更新（如 stop_reason）\n- `message_stop`: 消息结束",
            "enum": [
              "message_start",
              "ping",
              "content_block_start",
              "content_block_delta",
              "content_block_stop",
              "message_delta",
              "message_stop"
            ]
          },
          "message": {
            "type": "object",
            "description": "消息对象（`type` 为 `message_start` 时返回）",
            "properties": {
              "id": {
                "type": "string",
                "description": "消息的唯一 ID"
              },
              "type": {
                "type": "string",
                "enum": [
                  "message"
                ]
              },
              "role": {
                "type": "string",
                "enum": [
                  "assistant"
                ]
              },
              "content": {
                "type": "array",
                "description": "内容块列表，初始为空数组",
                "items": {
                  "$ref": "#/components/schemas/ResponseContentBlock"
                }
              },
              "model": {
                "type": "string",
                "description": "模型 ID"
              },
              "stop_reason": {
                "type": "string",
                "nullable": true,
                "description": "停止原因，流式开始时为 null"
              },
              "stop_sequence": {
                "type": "string",
                "nullable": true,
                "description": "停止序列，流式开始时为 null"
              },
              "usage": {
                "$ref": "#/components/schemas/Usage"
              }
            }
          },
          "index": {
            "type": "integer",
            "description": "内容块的索引（`content_block_start`、`content_block_delta`、`content_block_stop` 时返回）"
          },
          "content_block": {
            "$ref": "#/components/schemas/ResponseContentBlock",
            "description": "内容块对象（`type` 为 `content_block_start` 时返回）"
          },
          "delta": {
            "type": "object",
            "description": "增量更新内容（`content_block_delta` 或 `message_delta` 时返回）",
            "properties": {
              "type": {
                "type": "string",
                "description": "增量类型，例如 text_delta、thinking_delta 或 signature_delta。",
                "enum": [
                  "text_delta",
                  "thinking_delta",
                  "signature_delta"
                ]
              },
              "text": {
                "type": "string",
                "description": "增量文本内容"
              },
              "stop_reason": {
                "type": "string",
                "description": "模型停止生成的原因。",
                "enum": [
                  "end_turn",
                  "max_tokens",
                  "tool_use"
                ]
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage",
            "description": "Token 使用情况（`message_delta` 时返回）"
          }
        }
      },
      "CacheControl": {
        "type": "object",
        "description": "提示词缓存标记。",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "ephemeral"
            ],
            "description": "提示词缓存标记。"
          }
        },
        "required": [
          "type"
        ]
      },
      "MediaSource": {
        "type": "object",
        "description": "图片或视频内容块的媒体来源。\n\n**支持的图片格式**\n\n| 格式 | 常见拓展名 | MIME Type |\n| :-- | :-- | :-- |\n| JPEG | .jpg, .jpeg | image/jpeg |\n| PNG | .png | image/png |\n| GIF | .gif | image/gif |\n| WEBP | .webp | image/webp |\n\n**支持的视频格式**\n\n| 格式 | 常见拓展名 | MIME Type |\n| :-- | :-- | :-- |\n| MP4 | .mp4 | video/mp4 |\n| AVI | .avi | video/avi 或 video/x-msvideo |\n| MOV | .mov | url 传入视频：对象存储请设置 Content-Type 为 video/quicktime；base64 编码：请使用 video/mov，即 data:video/mov;base64,<BASE64_ENCODING> |\n| MKV | .mkv | video/x-matroska |\n\n**多模态文件大小及容量限制**\n- URL / Base64 方式传入：视频文件 ≤ 50 MB，图片文件 ≤ 10 MB，请求体 ≤ 64 MB。\n- 使用 Files API 上传：以 `mm_file://{file_id}` 形式引用，单个视频最大 512 MB。",
        "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。视频还可使用 Files API 引用 `mm_file://{file_id}`，`file_id` 需先通过[文件上传](/api-reference/file-management-upload)接口上传视频后获取。"
          },
          "detail": {
            "type": "string",
            "enum": [
              "low",
              "default",
              "high"
            ],
            "default": "default",
            "description": "理解精细度，默认 default。\n\n图片输入时，单张图片粗略 token 用量估算：\n\n| detail | 粗略 token 用量 |\n| :-- | :-- |\n| low | 通常为几百 token，最高约 600 |\n| default | 通常约 1k-3k token，最高约 5k |\n| high | 通常为数千 token，最高约 15k+ |\n\n实际用量取决于图片尺寸和内容；请以 `POST /anthropic/v1/messages/count_tokens` 或响应中的 usage 为准。"
          },
          "fps": {
            "type": "number",
            "minimum": 0.2,
            "maximum": 5,
            "default": 1,
            "description": "视频抽帧频率，默认 1，范围 [0.2, 5]。\n- 取值越高：对画面变化越敏感，token 花费高、速度慢。\n- 取值越低：token 花费少、速度快，但对画面变化迟钝。"
          },
          "max_long_side_pixel": {
            "type": "integer",
            "minimum": 1,
            "description": "图片或视频帧最长边像素约束。"
          }
        },
        "required": [
          "type"
        ]
      },
      "Tool": {
        "type": "object",
        "description": "Anthropic 兼容工具调用的工具定义。",
        "properties": {
          "name": {
            "type": "string",
            "description": "工具名称。"
          },
          "description": {
            "type": "string",
            "description": "工具描述。"
          },
          "input_schema": {
            "type": "object",
            "description": "工具输入参数 JSON Schema。"
          },
          "cache_control": {
            "$ref": "#/components/schemas/CacheControl"
          }
        },
        "required": [
          "name",
          "input_schema"
        ]
      },
      "ToolChoice": {
        "type": "object",
        "description": "工具选择策略。仅支持 auto 和 none。",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "auto",
              "none"
            ],
            "description": "工具选择类型。"
          }
        },
        "required": [
          "type"
        ]
      },
      "CountTokensResp": {
        "type": "object",
        "description": "返回本次请求的输入 token 用量，不生成模型输出。",
        "properties": {
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "description": "错误响应。统一使用 HTTP 状态码 + JSON body。流式过程中出现错误时，会以 `event: error` SSE 事件下发，body 结构与此一致；客户端应在收到 error 后停止读取并清理本次会话状态。",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "error"
            ],
            "description": "固定为 `error`。"
          },
          "request_id": {
            "type": "string",
            "description": "本次请求的唯一标识，便于排查问题。"
          },
          "error": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "description": "错误类型。",
                "enum": [
                  "invalid_request_error",
                  "authentication_error",
                  "permission_error",
                  "not_found_error",
                  "request_too_large",
                  "rate_limit_error",
                  "api_error",
                  "overloaded_error"
                ]
              },
              "message": {
                "type": "string",
                "description": "错误详情。"
              }
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer API Key 鉴权。发送 Authorization: Bearer <API_KEY>。如果 Authorization 和 x-api-key 同时存在，优先使用 Authorization。"
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Anthropic 兼容 API Key 鉴权。发送 x-api-key: <API_KEY>。推荐使用 Authorization: Bearer <API_KEY>。"
      }
    }
  }
}
