# MiniMax Integration via LowCodeAPI

## Overview

MiniMax is an AI platform with text generation, speech synthesis, video generation, and music generation capabilities.

## Base Endpoint

```
https://api.lowcodeapi.com/minimax/
```

## Authentication

LowCodeAPI handles authentication automatically. You only need to:

1. **Sign up** at https://minimax.io
2. **Connect your account** in LowCodeAPI dashboard
3. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your MiniMax API key from database
- Apply it to each request with proper Bearer token header

**Auth Type**: `API Key` (Bearer Token)

## API Categories

- Video Generation AI
- Messages
- Chat
- Speech
- Video
- Music

## Common Endpoints

### Category: Messages

#### Create Message (Anthropic Compatible)

**Method**: `POST` | **LowCodeAPI Path**: `/anthropic/v1/messages`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/anthropic/v1/messages?api_token={api_token}
```

**Description**: Create a message using MiniMax models with Anthropic-compatible API format.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string | Yes | Model to use (MiniMax-M2.1, MiniMax-M2.1-lightning, MiniMax-M2) |
| `messages` | array | Yes | Array of message objects with role and content |
| `max_tokens` | number | Yes | Maximum tokens to generate |
| `system` | string | No | System prompt for the conversation |
| `temperature` | number | No | Amount of randomness (0.0-1.0, default: 1.0) |
| `top_p` | number | No | Nucleus sampling parameter |
| `top_k` | number | No | Only sample from top K options |
| `stream` | boolean | No | Enable streaming response |
| `stop_sequences` | array | No | Custom text sequences to stop generation |
| `tools` | array | No | Tool definitions the model may use |
| `tool_choice` | object | No | Controls which tool to use |
| `metadata` | object | No | Metadata about the request |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/minimax/anthropic/v1/messages?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M2.1",
    "max_tokens": 1024,
    "messages": [
      {
        "role": "user",
        "content": "Hello, how are you?"
      }
    ],
    "temperature": 0.9
  }'
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/text-anthropic-api

---

### Category: Chat

#### Create Chat Completion

**Method**: `POST` | **LowCodeAPI Path**: `/v1/chat/completions`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/v1/chat/completions?api_token={api_token}
```

**Description**: Create a chat completion using MiniMax models with OpenAI-compatible API format.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string | Yes | Model ID (MiniMax-M2.1, MiniMax-M2.1-lightning, MiniMax-M2) |
| `messages` | array | Yes | Array of message objects with role and content |
| `max_tokens` | number | No | Maximum number of tokens to generate |
| `temperature` | number | No | Sampling temperature (0.0-1.0, default: 1.0) |
| `top_p` | number | No | Nucleus sampling parameter |
| `stream` | boolean | No | Enable streaming response |
| `stop` | array | No | Up to 4 sequences to stop generation |
| `tools` | array | No | List of tools the model may call |
| `tool_choice` | object | No | Controls which tool is called |
| `n` | number | No | Number of completions to generate (only supports 1) |
| `user` | string | No | Unique identifier for end-user |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/minimax/v1/chat/completions?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M2.1",
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "Write a short poem about AI."
      }
    ],
    "max_tokens": 500,
    "temperature": 0.8
  }'
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/text-openai-api

---

### Category: Speech

#### Text to Speech

**Method**: `POST` | **LowCodeAPI Path**: `/v1/t2a_v2`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/v1/t2a_v2?api_token={api_token}
```

**Description**: Convert text to speech using MiniMax T2A models.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string | Yes | Model to use (speech-02-turbo) |
| `text` | string | Yes | Text to convert to speech |
| `voice_id` | string | No | Voice ID to use for synthesis |
| `speed` | number | No | Speech speed (0.5 to 2.0) |
| `vol` | number | No | Volume level |
| `pitch` | number | No | Pitch adjustment |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/minimax/v1/t2a_v2?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-02-turbo",
    "text": "Hello! Welcome to MiniMax text-to-speech service.",
    "speed": 1.0
  }'
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/speech-t2a-http

---

### Category: Video

#### Create Text to Video

**Method**: `POST` | **LowCodeAPI Path**: `/v1/video_generation`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/v1/video_generation?api_token={api_token}
```

**Description**: Create a text-to-video generation task.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string | Yes | Model to use (hailuo-02) |
| `prompt` | string | Yes | Text prompt describing the video |
| `duration` | number | No | Video duration in seconds |
| `aspect_ratio` | string | No | Video aspect ratio (16:9, 9:16, 1:1) |
| `resolution` | string | No | Video resolution |

**Example Request**:
```bash
# Returns task ID to query later for result
curl -X POST "https://api.lowcodeapi.com/minimax/v1/video_generation?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hailuo-02",
    "prompt": "A serene beach at sunset with gentle waves lapping at the shore",
    "duration": 6,
    "aspect_ratio": "16:9"
  }'
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/video-generation-t2v

---

#### Create Image to Video

**Method**: `POST` | **LowCodeAPI Path**: `/v1/video_generation`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/v1/video_generation?api_token={api_token}
```

**Description**: Create an image-to-video generation task.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string | Yes | Model to use (hailuo-2.3Fast) |
| `image_url` | string | Yes | URL of the input image |
| `duration` | number | No | Video duration in seconds |
| `aspect_ratio` | string | No | Video aspect ratio (16:9, 9:16, 1:1) |
| `resolution` | string | No | Video resolution |

**Example Request**:
```bash
# Convert static image to video
curl -X POST "https://api.lowcodeapi.com/minimax/v1/video_generation?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hailuo-2.3Fast",
    "image_url": "https://example.com/image.jpg",
    "duration": 4,
    "aspect_ratio": "16:9"
  }'
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/video-generation-i2v

---

#### Query Video Generation Task

**Method**: `GET` | **LowCodeAPI Path**: `/v1/video_generation/taskid`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/v1/video_generation/taskid?task_id={task_id}&api_token={api_token}
```

**Description**: Query the status and result of a video generation task.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `task_id` | string | Yes | Task ID returned from video generation request |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
# Check video generation status
# task_id from text-to-video or image-to-video response
curl -X GET "https://api.lowcodeapi.com/minimax/v1/video_generation/taskid?task_id=TASK_ID&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/video-generation-t2v

---

### Category: Music

#### Generate Music

**Method**: `POST` | **LowCodeAPI Path**: `/v1/music_generation`

**Full URL**:
```
https://api.lowcodeapi.com/minimax/v1/music_generation?api_token={api_token}
```

**Description**: Generate a song from lyrics and a prompt.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `model` | string | Yes | Model to use (music-2.0) |
| `prompt` | string | Yes | Description of style, mood, and scenario (10-2000 chars) |
| `lyrics` | string | Yes | Song lyrics with optional structure tags (10-3000 chars) |
| `stream` | boolean | No | Enable streaming output |
| `output_format` | string | No | Output format: url or hex |
| `audio_setting` | object | No | Audio output configuration |

**Example Request**:
```bash
# Generate music with custom lyrics
curl -X POST "https://api.lowcodeapi.com/minimax/v1/music_generation?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "music-2.0",
    "prompt": "An upbeat pop song with electronic beats and catchy melody",
    "lyrics": "[Verse 1]\nWalking down the street tonight\nFeeling everything is alright\n\n[Chorus]\nWe are living in the moment\nTime to show we own it",
    "output_format": "url"
  }'
```

**Official Documentation**: https://platform.minimax.io/docs/api-reference/music-generation

---

## Usage Examples

### Example 1: Chat Completion with Multiple Formats

Try both Anthropic and OpenAI compatible formats.

```bash
# Using OpenAI-compatible format
curl -X POST "https://api.lowcodeapi.com/minimax/v1/chat/completions?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M2.1",
    "messages": [
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ],
    "max_tokens": 500,
    "temperature": 0.7
  }'

# Using Anthropic-compatible format
curl -X POST "https://api.lowcodeapi.com/minimax/anthropic/v1/messages?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-M2.1",
    "max_tokens": 500,
    "messages": [
      {"role": "user", "content": "Explain quantum computing in simple terms."}
    ]
  }'
```

### Example 2: Generate and Check Video Status

Create videos from text or images.

```bash
# Generate video from text prompt
# Returns task_id for status checking
curl -X POST "https://api.lowcodeapi.com/minimax/v1/video_generation?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hailuo-02",
    "prompt": "A peaceful forest with sunlight filtering through the trees",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'

# Check task status periodically
# Use task_id from previous response
curl -X GET "https://api.lowcodeapi.com/minimax/v1/video_generation/taskid?task_id=TASK_ID&api_token=YOUR_API_TOKEN"

# Convert image to video
curl -X POST "https://api.lowcodeapi.com/minimax/v1/video_generation?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "hailuo-2.3Fast",
    "image_url": "https://example.com/landscape.jpg",
    "duration": 4
  }'
```

### Example 3: Text to Speech and Music Generation

Create audio content from text.

```bash
# Convert text to speech
curl -X POST "https://api.lowcodeapi.com/minimax/v1/t2a_v2?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "speech-02-turbo",
    "text": "Welcome to our audio tour. Please follow the guide.",
    "speed": 1.0
  }'

# Generate music with lyrics
curl -X POST "https://api.lowcodeapi.com/minimax/v1/music_generation?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "music-2.0",
    "prompt": "A cheerful acoustic guitar song with folk influences",
    "lyrics": "[Intro]\nGentle guitar strumming\n\n[Verse]\nThe sun comes up over the hills\nA brand new day, a brand new feel",
    "output_format": "url"
  }'
```

## Complete Endpoint Reference

For a complete list of all endpoints and their parameters, refer to:
- **OpenAPI Definition**: `https://backend.lowcodeapi.com/minimax/definition`
- **Official Provider Documentation**: https://platform.minimax.io/docs/api-reference/text-intro

## Rate Limits & Best Practices

- Video generation is async - poll task status until complete
- Use appropriate aspect ratios for your use case (16:9 for video, 9:16 for mobile)
- Lyrics should follow structure tags for better music generation
- Stream responses can improve perceived performance for long generations

## Error Handling

Standard HTTP status codes apply. For video generation, check task status to see if generation succeeded or failed.