텍스트 생성 (Chat Completions)

MiniMax 대규모 언어 모델 기반 채팅 완성 인터페이스입니다. OpenAI Chat Completions API 형식과 호환되어 OpenAI 호출을 직접 대체하여 사용할 수 있습니다.

API 엔드포인트

POST/text/chatcompletion_v2

채팅 완성 생성

요청 파라미터

파라미터타입필수설명
modelstring필수모델 이름, 예: MiniMax-M2.5
messagesarray필수대화 메시지 배열
temperaturenumber선택샘플링 온도, 범위 0-2, 기본값 0.7
max_tokensinteger선택생성할 최대 토큰 수
streamboolean선택스트리밍 출력 사용 여부
top_pnumber선택핵 샘플링 파라미터, 범위 0-1

요청 예시

요청 예시
{
  "model": "MiniMax-M2.5",
  "messages": [
    {"role": "system", "content": "你是一个有用的助手。"},
    {"role": "user", "content": "你好,介绍一下你自己"}
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "stream": false
}

응답 예시

응답 예시
{
  "id": "chatcmpl-xxxxx",
  "object": "chat.completion",
  "created": 1234567890,
  "model": "MiniMax-M2.5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!我是 MiniMax 的 AI 助手..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 50,
    "total_tokens": 70
  }
}

코드 예시

import requests

url = "https://your-proxy-domain.com/v1/text/chatcompletion_v2"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "model": "MiniMax-M2.5",
    "messages": [
        {"role": "system", "content": "你是一个有用的助手。"},
        {"role": "user", "content": "你好"}
    ],
    "temperature": 0.7,
    "max_tokens": 1024
}

response = requests.post(url, headers=headers, json=data)
print(response.json())