跳转到主要内容
POST
/
v1
/
responses
/
input_tokens
Token 估算
curl --request POST \
  --url https://api.minimaxi.com/v1/responses/input_tokens \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "model": "MiniMax-M3",
  "input": [
    {
      "type": "message",
      "role": "user",
      "content": "请帮我用 Python 实现一个支持泛型的快速排序算法,要求:1) 原地排序节省内存;2) 处理重复元素时使用三路划分;3) 小数组切换到插入排序优化;4) 提供完整的单元测试。最后还请解释一下三路划分相比经典 Lomuto 划分在重复键场景下的优势。"
    }
  ],
  "tools": [
    {
      "type": "function",
      "name": "search_docs",
      "description": "搜索 Python 标准库或第三方库的官方文档",
      "parameters": {
        "type": "object",
        "properties": {
          "library": {
            "type": "string",
            "description": "库名称,如 `typing`、`itertools`"
          },
          "query": {
            "type": "string",
            "description": "搜索关键词"
          }
        },
        "required": [
          "library",
          "query"
        ]
      }
    },
    {
      "type": "function",
      "name": "run_python",
      "description": "在沙箱中执行 Python 代码,返回标准输出和错误信息",
      "parameters": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "要执行的 Python 代码"
          },
          "timeout_seconds": {
            "type": "integer",
            "description": "执行超时时间(秒)",
            "default": 10
          }
        },
        "required": [
          "code"
        ]
      }
    }
  ]
}
'
{
  "object": "response.input_tokens",
  "input_tokens": 588
}

Documentation Index

Fetch the complete documentation index at: https://platform.minimaxi.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

授权

Authorization
string
header
必填

HTTP: Bearer Auth

  • Security Scheme Type: http
  • HTTP Authorization Scheme: Bearer API_key,用于验证账户信息,可在 账户管理>接口密钥 中查看

请求头

Content-Type
enum<string>
默认值:application/json
必填

请求体的媒介类型,请设置为 application/json,确保请求数据的格式为 JSON

可用选项:
application/json

请求体

application/json
model
string
必填

调用的模型名称,如 MiniMax-M3

示例:

"MiniMax-M3"

input
必填

对话内容,支持简单文本或完整对话历史数组

instructions
string

系统指令

tools
object[]

工具列表

tool_choice
enum<string>

工具选择策略:none 表示不调用任何工具;auto 表示由模型自动判断是否调用工具

可用选项:
none,
auto
text
object

输出格式控制

reasoning
object

思考强度控制。不传则采用 adaptive 模式(由模型自动判断)

响应

200 - application/json

成功响应

object
enum<string>
必填

对象类型,固定为 response.input_tokens

可用选项:
response.input_tokens
input_tokens
integer
必填

估算的输入 token 数