{
  "openapi": "3.1.0",
  "info": {
    "title": "MiniMax Text API",
    "description": "MiniMax text generation API with support for chat completion and streaming output",
    "license": {
      "name": "MIT"
    },
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api.minimax.io"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/text/chatcompletion_v2": {
      "post": {
        "summary": "Text Generation V2",
        "operationId": "chatCompletionV2",
        "tags": ["Text Generation"],
        "parameters": [
          {
            "name": "Content-Type",
            "in": "header",
            "required": true,
            "description": "The media type of the request body. Must be set to `application/json` to ensure the data is sent in JSON format.",
            "schema": {
              "type": "string",
              "enum": ["application/json"],
              "default": "application/json"
            }
          }
        ],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionReq"
              },
              "examples": {
                "Request": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash",
                    "messages": [
                      {
                        "role": "system",
                        "name": "MiniMax AI"
                      },
                      {
                        "role": "user",
                        "name": "user",
                        "content": "hello"
                      }
                    ]
                  }
                },
                "Stream": {
                  "value": {
                    "model": "MiniMax-M3.1-Flash",
                    "messages": [
                      {
                        "role": "system",
                        "name": "MiniMax AI"
                      },
                      {
                        "role": "user",
                        "name": "user",
                        "content": "hello"
                      }
                    ],
                    "stream": true
                  }
                },
                "Image": {
                  "value": {
                    "model": "MiniMax-Text-01",
                    "messages": [
                      {
                        "role": "system",
                        "name": "MiniMax AI",
                        "content": "MM Smart Assistant is a large language model independently developed by MiniMax, without relying on other products' APIs. MiniMax is a Chinese technology company dedicated to research in large-scale models."
                      },
                      {
                        "role": "user",
                        "name": "User",
                        "content": [
                          {
                            "type": "text",
                            "text": "What does this picture represent?"
                          },
                          {
                            "type": "image_url",
                            "image_url": {
                              "url": "https://cdn.hailuoai.com/prod/2024-09-18-16/user/multi_chat_file/9c0b5c14-ee88-4a5b-b503-4f626f018639.jpeg"
                            }
                          }
                        ]
                      }
                    ]
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResp"
                },
                "examples": {
                  "Request": {
                    "value": {
                      "id": "04ecb5d9b1921ae0fb0e8da9017a5474",
                      "choices": [
                        {
                          "finish_reason": "stop",
                          "index": 0,
                          "message": {
                            "content": "Hello! How can I assist you?",
                            "role": "assistant",
                            "name": "MiniMax AI",
                            "audio_content": "",
                            "reasoning_content": "...omitted"
                          }
                        }
                      ],
                      "created": 1755153113,
                      "model": "MiniMax-M3.1-Flash",
                      "object": "chat.completion",
                      "usage": {
                        "total_tokens": 249,
                        "total_characters": 0,
                        "prompt_tokens": 26,
                        "completion_tokens": 223,
                        "completion_tokens_details": {
                          "reasoning_tokens": 214
                        }
                      },
                      "input_sensitive": false,
                      "output_sensitive": false,
                      "input_sensitive_type": 0,
                      "output_sensitive_type": 0,
                      "output_sensitive_int": 0,
                      "base_resp": {
                        "status_code": 0,
                        "status_msg": ""
                      }
                    }
                  },
                  "Stream": {
                    "value": [
                      {
                        "id": "02ff7eb7fe6fb505b9d5cb6945a1a98b",
                        "choices": [
                          {
                            "index": 0,
                            "delta": { "content": "Okay", "role": "assistant" }
                          }
                        ],
                        "created": 1722829751,
                        "model": "MiniMax-M3.1-Flash",
                        "object": "chat.completion.chunk",
                        "output_sensitive": false,
                        "input_sensitive_type": 0,
                        "output_sensitive_type": 0
                      },
                      {
                        "id": "02ff7eb7fe6fb505b9d5cb6945a1a98b",
                        "choices": [
                          {
                            "finish_reason": "stop",
                            "index": 0,
                            "delta": {
                              "content": "Hello! How can I assist you today?",
                              "role": "assistant"
                            }
                          }
                        ],
                        "created": 1722829751,
                        "model": "MiniMax-M3.1-Flash",
                        "object": "chat.completion.chunk",
                        "output_sensitive": false,
                        "input_sensitive_type": 0,
                        "output_sensitive_type": 0
                      },
                      {
                        "id": "02ff7eb7fe6fb505b9d5cb6945a1a98b",
                        "choices": [
                          {
                            "finish_reason": "stop",
                            "index": 0,
                            "message": {
                              "content": "Hello! How can I assist you today?",
                              "role": "assistant"
                            }
                          }
                        ],
                        "created": 1722829751,
                        "model": "MiniMax-M3.1-Flash",
                        "object": "chat.completion",
                        "usage": { "total_tokens": 73 },
                        "input_sensitive": false,
                        "output_sensitive": false,
                        "input_sensitive_type": 0,
                        "output_sensitive_type": 0,
                        "base_resp": { "status_code": 0, "status_msg": "" }
                      }
                    ]
                  },
                  "Image": {
                    "value": {
                      "content": "This picture represents a cute and whimsical scene where a hamster is depicted as if it is having a cup of tea. The hamster is placed on a small wooden table with a miniature teacup and saucer, creating a charming and playful atmosphere. The setting includes small potted plants and a clock in the background, adding to the cozy and homely feel of the image.",
                      "role": "assistant",
                      "name": "MiniMax AI",
                      "audio_content": ""
                    }
                  }
                }
              },
              "text/event-stream": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResp"
                },
                "examples": {
                  "Stream": {
                    "value": [
                      {
                        "id": "02ff7eb7fe6fb505b9d5cb6945a1a98b",
                        "choices": [
                          {
                            "index": 0,
                            "delta": { "content": "Okay", "role": "assistant" }
                          }
                        ],
                        "created": 1722829751,
                        "model": "MiniMax-M3.1-Flash",
                        "object": "chat.completion.chunk",
                        "output_sensitive": false,
                        "input_sensitive_type": 0,
                        "output_sensitive_type": 0
                      },
                      {
                        "id": "02ff7eb7fe6fb505b9d5cb6945a1a98b",
                        "choices": [
                          {
                            "finish_reason": "stop",
                            "index": 0,
                            "delta": {
                              "content": "Hello! How can I assist you today?",
                              "role": "assistant"
                            }
                          }
                        ],
                        "created": 1722829751,
                        "model": "MiniMax-M3.1-Flash",
                        "object": "chat.completion.chunk",
                        "output_sensitive": false,
                        "input_sensitive_type": 0,
                        "output_sensitive_type": 0
                      },
                      {
                        "id": "02ff7eb7fe6fb505b9d5cb6945a1a98b",
                        "choices": [
                          {
                            "finish_reason": "stop",
                            "index": 0,
                            "message": {
                              "content": "Hello! How can I assist you today?",
                              "role": "assistant"
                            }
                          }
                        ],
                        "created": 1722829751,
                        "model": "MiniMax-M3.1-Flash",
                        "object": "chat.completion",
                        "usage": { "total_tokens": 73 },
                        "input_sensitive": false,
                        "output_sensitive": false,
                        "input_sensitive_type": 0,
                        "output_sensitive_type": 0,
                        "base_resp": { "status_code": 0, "status_msg": "" }
                      }
                    ]
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "ChatCompletionReq": {
        "type": "object",
        "required": ["model", "messages"],
        "properties": {
          "model": {
            "type": "string",
            "description": "Model ID. Supports `MiniMax-M3.1-Flash` and `MiniMax-M3`. Both are reasoning models; streaming output is recommended for the best experience.",
            "enum": ["MiniMax-M3.1-Flash", "MiniMax-M3"]
          },
          "stream": {
            "type": "boolean",
            "description": "Whether to enable streaming. Defaults to `false`. If `true`, the response will be returned in multiple chunks.",
            "default": false
          },
          "max_tokens": {
            "type": "integer",
            "format": "int64",
            "description": "Deprecated in favor of `max_completion_tokens`.\n\nMaximum number of tokens allowed in the generated output. Content beyond this limit will be truncated. If the generation is cut off due to length limits, consider increasing this value.\n\nDefault:\n- `MiniMax-M2`: 10240\n- `MiniMax-M1`: 8192\n- `MiniMax-Text-01`: 2048",
            "minimum": 1,
            "deprecated": true
          },
          "max_completion_tokens": {
            "type": "integer",
            "format": "int64",
            "description": "Maximum number of tokens allowed in the generated output. Content beyond this limit will be truncated. If the generation is cut off due to length limits, consider increasing this value.\n\nDefault:\n- `MiniMax-M2`: 10240\n- `MiniMax-M1`: 8192\n- `MiniMax-Text-01`: 2048",
            "minimum": 1
          },
          "temperature": {
            "type": "number",
            "format": "double",
            "description": "Controls randomness of the output. Range: (0, 1]. Higher values will make the output more random, while lower values will make it more focused and deterministic.\n\nDefault values:\n- `MiniMax-M2`: recommended 1.0\n-`MiniMax-M1`: 1.0 (recommended range [0.8, 1.0])\n- `MiniMax-Text-01`: 0.1 (can be raised to 0.7–1.0 for creative tasks).",
            "minimum": 0.0,
            "exclusiveMinimum": 0.0,
            "maximum": 1.0
          },
          "top_p": {
            "type": "number",
            "format": "double",
            "description": "Sampling strategy that affects output diversity. Range: (0, 1]\n- `MiniMax-M2` recommended 0.95",
            "minimum": 0.0,
            "exclusiveMinimum": 0.0,
            "maximum": 1.0,
            "default": 0.95
          },
          "messages": {
            "type": "array",
            "description": "List of messages containing conversation history",
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "tool_choice": {
            "type": "string",
            "description": "Controls how the model uses tools. `auto`: the model decides whether to call tools (default)",
            "enum": ["auto"],
            "default": "auto"
          },
          "tools": {
            "type": "array",
            "description": "List of tools available for the model to call. For more details, see [M2 Tool Use & Interleaved Thinking](/guides/text-m3-function-call)",
            "items": {
              "type": "object",
              "required": ["type", "function"],
              "properties": {
                "type": {
                  "type": "string",
                  "description": "Tool type. Currently only `function` is supported.",
                  "enum": ["function"]
                },
                "function": {
                  "type": "object",
                  "required": ["name", "description", "parameters"],
                  "description": "Function definition.",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Function name."
                    },
                    "description": {
                      "type": "string",
                      "description": "Description of the function's purpose, behavior, and parameters."
                    },
                    "parameters": {
                      "type": "object",
                      "description": "Function parameters."
                    }
                  }
                }
              }
            }
          },
          "response_format": {
            "type": "object",
            "description": "Specifies the output format (only supported by `MiniMax-Text-01`).\nExample: `{ \"type\": \"json_schema\", \"json_schema\": {...} }`",
            "required": ["type", "json_schema"],
            "properties": {
              "type": {
                "type": "string",
                "description": "Format type. Only `json_schema` is supported.",
                "enum": ["json_schema"]
              },
              "json_schema": {
                "type": "object",
                "description": "Schema definition for structured output.",
                "required": ["name", "schema"],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Schema name. Max length: 64. Must match regex: `\\w`.",
                    "maxLength": 64,
                    "pattern": "^\\w+$"
                  },
                  "description": {
                    "type": "string",
                    "description": "Description of the schema, helps model understand output format."
                  },
                  "schema": {
                    "type": "object",
                    "description": "JSON Schema definition.",
                    "required": ["type", "properties"],
                    "properties": {
                      "type": {
                        "type": "string",
                        "description": "Must be `object`.",
                        "enum": ["object"]
                      },
                      "properties": {
                        "type": "object",
                        "description": "Define each field in the output object. Supports types: String, Array, Enum, Number, Integer, Object, Boolean.\n\n**Example:**\n\n```json\n\"json_schema\": {\n  \"name\": \"user_analysis\",\n  \"description\": \"User behavior analysis result\",\n  \"schema\": {\n    \"type\": \"object\",\n    \"properties\": {\n      \"analysis\": {\n        \"type\": \"string\",\n        \"description\": \"Content analysis based on rules\"\n      },\n      \"summary_words\": {\n        \"type\": \"array\",\n        \"items\": {\n          \"type\": \"string\"\n        },\n        \"description\": \"Content keywords summary, limited to three words\"\n      },\n      \"content_result\": {\n        \"type\": \"string\",\n        \"enum\": [\n          \"Pornography/Obscenity Violation\",\n          \"Advertising/Spam Violation\",\n          \"Illegal Content Violation\",\n          \"Political Content Violation\",\n          \"Self-harm/Suicide Violation\",\n          \"Underage Violation\",\n          \"Abuse/Insult Violation\",\n          \"Other Violations\",\n          \"Normal\"\n        ],\n        \"description\": \"Content classification result\"\n      },\n      \"risk_words\": {\n        \"type\": \"array\",\n        \"items\": {\n          \"type\": \"string\"\n        },\n        \"description\": \"Keywords indicating violations, emojis converted to text\"\n      },\n      \"correct_rate\": {\n        \"type\": \"number\",\n        \"description\": \"Credibility score, from 0.00 to 1.00\"\n      },\n      \"content_risk_level\": {\n        \"type\": \"string\",\n        \"enum\": [\"high\", \"medium\", \"low\"],\n        \"description\": \"Risk concentration level in content\"\n      }\n    },\n    \"required\": [\n      \"analysis\",\n      \"summary_words\",\n      \"content_result\",\n      \"risk_words\",\n      \"correct_rate\",\n      \"content_risk_level\"\n    ]\n  }\n}\n```"
                      }
                    }
                  }
                }
              }
            }
          },
          "stream_options": {
            "type": "object",
            "description": "Options for streaming mode.",
            "properties": {
              "include_usage": {
                "type": "boolean",
                "description": "Defaults to `false`. If `true`, the final chunk will include complete `usage` statistics.",
                "default": false
              }
            }
          },
          "mask_sensitive_info": {
            "type": "boolean",
            "description": "Mask (replace with ***) content in the output that involves private information, including but not limited to email, domain, link, ID number, home address, etc.\n\nDefaults `false`.",
            "default": false
          }
        },
        "example": {
                      "model": "MiniMax-M3.1-Flash",
          "messages": [
            {
              "role": "system",
              "name": "MiniMax AI"
            },
            {
              "role": "user",
              "name": "user",
              "content": "hello"
            }
          ]
        }
      },
      "ChatCompletionResp": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "Unique ID of this response."
          },
          "choices": {
            "type": "array",
            "description": "List of response choices.",
            "items": {
              "type": "object",
              "properties": {
                "finish_reason": {
                  "type": "string",
                  "description": "Reason the generation stopped:\n- `stop`: completed naturally\n- `length`: reached max_tokens limit\n- `tool_calls`: tool call triggered",
                  "enum": ["stop", "length", "tool_calls"]
                },
                "index": {
                  "type": "integer",
                  "description": "Index of the choice (starting at 0)."
                },
                "message": {
                  "type": "object",
                  "description": "The complete reply generated by the model.",
                  "required": ["content", "role"],
                  "properties": {
                    "content": {
                      "type": "string",
                      "description": "Text reply content."
                    },
                    "role": {
                      "type": "string",
                      "description": "Role of the message. Fixed value: `assistant`.",
                      "enum": ["assistant"]
                    },
                    "tool_calls": {
                      "type": "array",
                      "description": "List of tools requested by the model.",
                      "items": {
                        "type": "object",
                        "required": ["id", "type", "function"],
                        "properties": {
                          "id": {
                            "type": "string",
                            "description": "Unique tool call ID."
                          },
                          "type": {
                            "type": "string",
                            "description": "Always `function`.",
                            "enum": ["function"]
                          },
                          "function": {
                            "type": "object",
                            "description": "Function calling information.",
                            "required": ["name", "arguments"],
                            "properties": {
                              "name": {
                                "type": "string",
                                "description": "name of function."
                              },
                              "arguments": {
                                "type": "string",
                                "description": "JSON string of arguments."
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "created": {
            "type": "integer",
            "format": "int64",
            "description": "Unix timestamp (seconds) when the response was created."
          },
          "model": {
            "type": "string",
            "description": "Model ID used for this request."
          },
          "object": {
            "type": "string",
            "description": "Object type:\n- `chat.completion`: non-streaming\n- `chat.completion.chunk`: streaming",
            "enum": ["chat.completion", "chat.completion.chunk"]
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "input_sensitive": {
            "type": "boolean",
            "description": "Whether the input contained sensitive content. See `input_sensitive_type` for details on the type of sensitive content."
          },
          "input_sensitive_type": {
            "type": "integer",
            "format": "int64",
            "description": "Type of sensitive content in input. Possible values:\n\n`1`: severe violation\n`2`: pornography\n`3`: advertising\n`4`: prohibited\n`5`: abusive\n`6`: terrorism/violence\n`7`: other"
          },
          "output_sensitive": {
            "type": "boolean",
            "description": "Whether the output contained sensitive content."
          },
          "output_sensitive_type": {
            "type": "integer",
            "format": "int64",
            "description": "Type of sensitive content in output."
          },
          "base_resp": {
            "type": "object",
            "description": "Error status codes and details.",
            "properties": {
              "status_code": {
                "type": "integer",
                "format": "int64",
                "description": "Error code. Examples:\n\n`1000`: Unknown error\n`1001`: Request timeout\n`1002`: Rate limited\n`1004`: Authentication failed\n`1008`: Insufficient balance\n`1013`: Internal server error\n`1027`: Invalid output content\n`1039`: Token limit exceeded\n`2013`: Invalid parameters\n\nFor more information, please refer to the [Error Code Reference](/api-reference/errorcode)."
              },
              "status_msg": {
                "type": "string",
                "description": "Error details."
              }
            }
          }
        },
        "example": {
          "id": "04ecb5d9b1921ae0fb0e8da9017a5474",
          "choices": [
            {
              "finish_reason": "stop",
              "index": 0,
              "message": {
                "content": "Hello! How can I assist you?",
                "role": "assistant",
                "name": "MiniMax AI",
                "audio_content": "",
                "reasoning_content": "...omitted"
              }
            }
          ],
          "created": 1755153113,
                      "model": "MiniMax-M3.1-Flash",
          "object": "chat.completion",
          "usage": {
            "total_tokens": 249,
            "total_characters": 0,
            "prompt_tokens": 26,
            "completion_tokens": 223,
            "completion_tokens_details": {
              "reasoning_tokens": 214
            }
          },
          "input_sensitive": false,
          "output_sensitive": false,
          "input_sensitive_type": 0,
          "output_sensitive_type": 0,
          "output_sensitive_int": 0,
          "base_resp": {
            "status_code": 0,
            "status_msg": ""
          }
        }
      },
      "Message": {
        "type": "object",
        "required": ["role", "content"],
        "properties": {
          "role": {
            "type": "string",
            "enum": ["system", "user", "assistant", "tool"],
            "description": "The role of the message sender:\n- `system`: set the model's role and behavior\n- `user`: user input\n- `assistant`: model responses, may include tool calls\n- `tool`: returned result from a tool call"
          },
          "name": {
            "type": "string",
            "description": "Name of the sender. Optional parameter. Required if multiple senders share the same role."
          },
          "content": {
            "description": "Message content. Supports two types: `string` and `object[]`",
            "oneOf": [
              {
                "type": "string",
                "description": "Plain `string` message content"
              },
              {
                "type": "array",
                "description": "Multimodal message content (`array`)",
                "items": {
                  "type": "object",
                  "required": ["type"],
                  "properties": {
                    "type": {
                      "type": "string",
                      "enum": ["text", "image_url"],
                      "description": "Content type. Options: `text`, `image_url`."
                    },
                    "text": {
                      "type": "string",
                      "description": "Text content."
                    },
                    "image_url": {
                      "type": "object",
                      "required": ["url"],
                      "properties": {
                        "url": {
                          "type": "string",
                          "description": "Public image URL or Base64-encoded Data."
                        }
                      },
                      "description": "Image input."
                    }
                  }
                }
              }
            ]
          },
          "tool_calls": {
            "type": "array",
            "description": "List of tools the model decides to invoke (appears when `role=assistant`).",
            "items": {
              "type": "object",
              "required": ["id", "type", "function"],
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique ID of the tool call."
                },
                "type": {
                  "type": "string",
                  "description": "Tool type. Fixed value: `function`.",
                  "enum": ["function"]
                },
                "function": {
                  "type": "object",
                  "required": ["name", "arguments"],
                  "description": "Details of the function call.",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Name of the function to be called."
                    },
                    "arguments": {
                      "type": "string",
                      "description": "JSON string containing the function call arguments."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "Choice": {
        "type": "object",
        "properties": {
          "index": {
            "type": "integer",
            "description": "Index of the choice"
          },
          "message": {
            "$ref": "#/components/schemas/Message"
          },
          "finish_reason": {
            "type": "string",
            "enum": ["stop", "length", "content_filter"],
            "description": "Reason for completion"
          }
        }
      },
      "Usage": {
        "type": "object",
        "description": "Token usage statistics for this request.",
        "properties": {
          "total_tokens": {
            "type": "integer",
            "description": "Total number of tokens consumed."
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "`HTTP: Bearer Auth`\n- Security Scheme Type: http\n- HTTP Authorization Scheme: `Bearer API_key`, can be found in [Account Management>API Keys](https://platform.minimax.io/user-center/basic-information/interface-key)."
      }
    }
  }
}
