Chat · MiniMax

Chat Completions

Generate conversational responses using MiniMax language models through the unified chat completions endpoint.

POST/v1/chat/completions

Supported Models

ModelProvider
MiniMax-M1MiniMax

Request

Body Parameters

modelstringrequired

Model ID — use "MiniMax-M1"

messagesarrayrequired

Array of message objects with role and content

temperaturenumber

Sampling temperature (0-2)

Default: 1

max_tokensinteger

Maximum tokens to generate

top_pnumber

Nucleus sampling parameter

Default: 1

streamboolean

Enable server-sent events streaming

Default: false

stopstring | string[]

Stop sequences to halt generation

frequency_penaltynumber

Frequency penalty (-2 to 2)

Default: 0

presence_penaltynumber

Presence penalty (-2 to 2)

Default: 0

toolsarray

List of tools (functions) the model can call

tool_choicestring | object

Control tool selection behavior

Options: auto, none, required

response_formatobject

Force output format

Options: text, json_object

cURL
curl https://api.metriqual.com/v1/chat/completions \
  -H "Authorization: Bearer mql_your_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M1",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "What is quantum computing?"}
    ],
    "temperature": 0.7,
    "max_tokens": 500
  }'
TypeScript SDK
const response = await mql.chat.create({
  model: 'MiniMax-M1',
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is quantum computing?' }
  ],
  temperature: 0.7,
  max_tokens: 500
});

console.log(response.choices[0].message.content);
Python SDK
response = mql.chat.create(
    model="MiniMax-M1",
    messages=[
        {"role": "system", "content": "You are a helpful assistant."},
        {"role": "user", "content": "What is quantum computing?"},
    ],
    temperature=0.7,
    max_tokens=500,
)
print(response["choices"][0]["message"]["content"])

Response

Response Fields

idstring

Unique completion ID

objectstring

Always "chat.completion"

createdinteger

Unix timestamp

modelstring

Model used for completion

choicesarray

Array of completion choices

usageobject

Token usage statistics

200
{
  "id": "chatcmpl-minimax-abc123",
  "object": "chat.completion",
  "created": 1705320000,
  "model": "MiniMax-M1",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum computing is a type of computation..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 25,
    "completion_tokens": 150,
    "total_tokens": 175
  }
}

Streaming

Set stream: true to receive incremental responses via Server-Sent Events.

TypeScript SDK Streaming
// Using async iterator
for await (const chunk of mql.chat.stream({
  model: 'MiniMax-M1',
  messages: [{ role: 'user', content: 'Tell me a story' }]
})) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}
Python SDK Streaming
for chunk in mql.chat.stream(
    model="MiniMax-M1",
    messages=[{"role": "user", "content": "Tell me a story"}],
):
    print(chunk["choices"][0]["delta"].get("content", ""), end="")