跳转到主要内容
POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://api.minimaxi.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "model": "MiniMax-M2.7",
  "messages": [
    {
      "role": "system",
      "name": "MiniMax AI"
    },
    {
      "role": "user",
      "name": "用户",
      "content": "你好"
    }
  ]
}
'
{
  "id": "06379b8377842dc0108975f159dc3e7c",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "message": {
        "content": "<think>用户用中文打招呼,我应该用中文回应。</think>\n\n你好!有什么我可以帮助你的吗?",
        "role": "assistant"
      }
    }
  ],
  "created": 1776838788,
  "model": "MiniMax-M2.7",
  "object": "chat.completion",
  "usage": {
    "total_tokens": 43,
    "total_characters": 0,
    "prompt_tokens": 22,
    "completion_tokens": 21,
    "prompt_tokens_details": {
      "cached_tokens": 0
    }
  },
  "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": "success"
  }
}

授权

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
enum<string>
必填

模型 ID

可用选项:
MiniMax-M2.7,
MiniMax-M2.7-highspeed,
MiniMax-M2.5,
MiniMax-M2.1
messages
object[]
必填

包含对话历史的消息列表。更多 message 参数说明请参考 文本对话使用指南

stream
boolean
默认值:false

是否使用流式传输,默认为 false。设置为 true 后,响应将分批返回

max_completion_tokens
integer<int64>

指定生成内容长度的上限(Token 数),上限为 2048。超过上限的内容会被截断。如果生成因 length 原因中断,请尝试调高此值

必填范围: x >= 1
temperature
number<double>
默认值:1

温度系数,影响输出随机性,取值范围 (0, 1],模型默认值为 1.0。值越高,输出越随机;值越低,输出越确定

必填范围: 0 < x <= 1
top_p
number<double>
默认值:0.95

采样策略,影响输出随机性,取值范围 (0, 1],模型默认值为 0.95

必填范围: 0 < x <= 1

响应

id
string

本次响应的唯一 ID

choices
object[]

响应选择列表

created
integer<int64>

响应创建的 Unix 时间戳(秒)

model
string

本次请求使用的模型 ID

object
enum<string>

对象类型。非流式为 chat.completion,流式为 chat.completion.chunk

可用选项:
chat.completion,
chat.completion.chunk
usage
object

本次请求的 Token 使用情况统计

input_sensitive
boolean

输入内容是否命中敏感词。如果输入内容严重违规,接口会返回内容违规错误信息,回复内容为空

input_sensitive_type
integer<int64>

输入命中敏感词类型,当input_sensitive为true时返回。取值为以下其一:1 严重违规;2 色情;3 广告;4 违禁;5 谩骂;6 暴恐;7 其他

output_sensitive
boolean

输出内容是否命中敏感词。如果输出内容严重违规,接口会返回内容违规错误信息,回复内容为空

output_sensitive_type
integer<int64>

输出命中敏感词类型

base_resp
object

错误状态码和详情