Skip to main content
POST
/
v1
/
responses
/
input_tokens
Estimate Input Tokens
curl --request POST \
  --url https://api.minimax.io/v1/responses/input_tokens \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "model": "MiniMax-M3",
  "input": [
    {
      "type": "message",
      "role": "user",
      "content": "Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat."
    }
  ],
  "tools": [
    {
      "type": "function",
      "name": "search_docs",
      "description": "Search the official documentation of the Python standard library or a third-party package",
      "parameters": {
        "type": "object",
        "properties": {
          "library": {
            "type": "string",
            "description": "Library name, e.g. `typing`, `itertools`"
          },
          "query": {
            "type": "string",
            "description": "Search keywords"
          }
        },
        "required": [
          "library",
          "query"
        ]
      }
    },
    {
      "type": "function",
      "name": "run_python",
      "description": "Execute Python code in a sandbox and return stdout / error",
      "parameters": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string",
            "description": "Python code to execute"
          },
          "timeout_seconds": {
            "type": "integer",
            "description": "Execution timeout in seconds",
            "default": 10
          }
        },
        "required": [
          "code"
        ]
      }
    }
  ]
}
'
import requests

url = "https://api.minimax.io/v1/responses/input_tokens"

payload = {
"model": "MiniMax-M3",
"input": [
{
"type": "message",
"role": "user",
"content": "Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat."
}
],
"tools": [
{
"type": "function",
"name": "search_docs",
"description": "Search the official documentation of the Python standard library or a third-party package",
"parameters": {
"type": "object",
"properties": {
"library": {
"type": "string",
"description": "Library name, e.g. `typing`, `itertools`"
},
"query": {
"type": "string",
"description": "Search keywords"
}
},
"required": ["library", "query"]
}
},
{
"type": "function",
"name": "run_python",
"description": "Execute Python code in a sandbox and return stdout / error",
"parameters": {
"type": "object",
"properties": {
"code": {
"type": "string",
"description": "Python code to execute"
},
"timeout_seconds": {
"type": "integer",
"description": "Execution timeout in seconds",
"default": 10
}
},
"required": ["code"]
}
}
]
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
model: 'MiniMax-M3',
input: [
{
type: 'message',
role: 'user',
content: 'Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat.'
}
],
tools: [
{
type: 'function',
name: 'search_docs',
description: 'Search the official documentation of the Python standard library or a third-party package',
parameters: {
type: 'object',
properties: {
library: {type: 'string', description: 'Library name, e.g. `typing`, `itertools`'},
query: {type: 'string', description: 'Search keywords'}
},
required: ['library', 'query']
}
},
{
type: 'function',
name: 'run_python',
description: 'Execute Python code in a sandbox and return stdout / error',
parameters: {
type: 'object',
properties: {
code: {type: 'string', description: 'Python code to execute'},
timeout_seconds: {type: 'integer', description: 'Execution timeout in seconds', default: 10}
},
required: ['code']
}
}
]
})
};

fetch('https://api.minimax.io/v1/responses/input_tokens', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.minimax.io/v1/responses/input_tokens",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'MiniMax-M3',
'input' => [
[
'type' => 'message',
'role' => 'user',
'content' => 'Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat.'
]
],
'tools' => [
[
'type' => 'function',
'name' => 'search_docs',
'description' => 'Search the official documentation of the Python standard library or a third-party package',
'parameters' => [
'type' => 'object',
'properties' => [
'library' => [
'type' => 'string',
'description' => 'Library name, e.g. `typing`, `itertools`'
],
'query' => [
'type' => 'string',
'description' => 'Search keywords'
]
],
'required' => [
'library',
'query'
]
]
],
[
'type' => 'function',
'name' => 'run_python',
'description' => 'Execute Python code in a sandbox and return stdout / error',
'parameters' => [
'type' => 'object',
'properties' => [
'code' => [
'type' => 'string',
'description' => 'Python code to execute'
],
'timeout_seconds' => [
'type' => 'integer',
'description' => 'Execution timeout in seconds',
'default' => 10
]
],
'required' => [
'code'
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.minimax.io/v1/responses/input_tokens"

payload := strings.NewReader("{\n \"model\": \"MiniMax-M3\",\n \"input\": [\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": \"Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"search_docs\",\n \"description\": \"Search the official documentation of the Python standard library or a third-party package\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"library\": {\n \"type\": \"string\",\n \"description\": \"Library name, e.g. `typing`, `itertools`\"\n },\n \"query\": {\n \"type\": \"string\",\n \"description\": \"Search keywords\"\n }\n },\n \"required\": [\n \"library\",\n \"query\"\n ]\n }\n },\n {\n \"type\": \"function\",\n \"name\": \"run_python\",\n \"description\": \"Execute Python code in a sandbox and return stdout / error\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"code\": {\n \"type\": \"string\",\n \"description\": \"Python code to execute\"\n },\n \"timeout_seconds\": {\n \"type\": \"integer\",\n \"description\": \"Execution timeout in seconds\",\n \"default\": 10\n }\n },\n \"required\": [\n \"code\"\n ]\n }\n }\n ]\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.minimax.io/v1/responses/input_tokens")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"model\": \"MiniMax-M3\",\n \"input\": [\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": \"Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"search_docs\",\n \"description\": \"Search the official documentation of the Python standard library or a third-party package\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"library\": {\n \"type\": \"string\",\n \"description\": \"Library name, e.g. `typing`, `itertools`\"\n },\n \"query\": {\n \"type\": \"string\",\n \"description\": \"Search keywords\"\n }\n },\n \"required\": [\n \"library\",\n \"query\"\n ]\n }\n },\n {\n \"type\": \"function\",\n \"name\": \"run_python\",\n \"description\": \"Execute Python code in a sandbox and return stdout / error\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"code\": {\n \"type\": \"string\",\n \"description\": \"Python code to execute\"\n },\n \"timeout_seconds\": {\n \"type\": \"integer\",\n \"description\": \"Execution timeout in seconds\",\n \"default\": 10\n }\n },\n \"required\": [\n \"code\"\n ]\n }\n }\n ]\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.minimax.io/v1/responses/input_tokens")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"model\": \"MiniMax-M3\",\n \"input\": [\n {\n \"type\": \"message\",\n \"role\": \"user\",\n \"content\": \"Please implement a generic quicksort algorithm in Python with these requirements: 1) in-place sorting to save memory; 2) three-way partitioning to handle duplicate elements; 3) switch to insertion sort for small subarrays; 4) include complete unit tests. Finally, explain the advantage of three-way partitioning over the classic Lomuto scheme when keys repeat.\"\n }\n ],\n \"tools\": [\n {\n \"type\": \"function\",\n \"name\": \"search_docs\",\n \"description\": \"Search the official documentation of the Python standard library or a third-party package\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"library\": {\n \"type\": \"string\",\n \"description\": \"Library name, e.g. `typing`, `itertools`\"\n },\n \"query\": {\n \"type\": \"string\",\n \"description\": \"Search keywords\"\n }\n },\n \"required\": [\n \"library\",\n \"query\"\n ]\n }\n },\n {\n \"type\": \"function\",\n \"name\": \"run_python\",\n \"description\": \"Execute Python code in a sandbox and return stdout / error\",\n \"parameters\": {\n \"type\": \"object\",\n \"properties\": {\n \"code\": {\n \"type\": \"string\",\n \"description\": \"Python code to execute\"\n },\n \"timeout_seconds\": {\n \"type\": \"integer\",\n \"description\": \"Execution timeout in seconds\",\n \"default\": 10\n }\n },\n \"required\": [\n \"code\"\n ]\n }\n }\n ]\n}"

response = http.request(request)
puts response.read_body
{
  "object": "response.input_tokens",
  "input_tokens": 588
}

Authorizations

Authorization
string
header
required

HTTP: Bearer Auth

  • Security Scheme Type: http
  • HTTP Authorization Scheme: Bearer API_key, used to authenticate your account. View it in Account Management > API Keys

Headers

Content-Type
enum<string>
default:application/json
required

Media type of the request body. Must be set to application/json

Available options:
application/json

Body

application/json
model
string
required

Model name to invoke, e.g. MiniMax-M3

Example:

"MiniMax-M3"

input
required

Conversation content. Supports either a simple text or a full conversation history array

instructions
string

System instructions

tools
object[]

Tool list

tool_choice
enum<string>

Tool selection strategy: none means no tool will be called; auto lets the model decide whether to call tools

Available options:
none,
auto
text
object

Output format control

reasoning
object

Reasoning control. For MiniMax-M3, the default is none, which disables reasoning. Set effort to a non-none value (minimal, low, medium, or high) to enable Adaptive Thinking, but this does not tune MiniMax-M3's reasoning depth. For M2.x models, reasoning cannot be disabled.

Response

200 - application/json

Successful response

object
enum<string>
required

Object type, always response.input_tokens

Available options:
response.input_tokens
input_tokens
integer
required

Estimated input token count