mmx-sdk
v1.0.5
Published
SDK for the MiniMax AI Platform
Readme
Frontend Engineer · Open Source Enthusiast · Open to Work
Features
- Text — Multi-turn chat, streaming, system prompts, JSON output
- Image — Text-to-image with aspect ratio and batch controls
- Video — Async video generation with progress tracking
- Speech — TTS with 30+ voices, speed control, streaming playback
- Music — Text-to-music with optional lyrics
- Vision — Image understanding and description
- Search — Web search powered by MiniMax
- Dual Region — Seamless Global (
api.minimax.io) and CN (api.minimaxi.com) support
Install
npm install mmx-sdkRequires Node.js 18+
Quick Start
import { MiniMaxSDK } from 'mmx-sdk';
const sdk = new MiniMaxSDK({ apiKey: 'sk-xxxxx' });
// Text chat
const response = await sdk.chat({ message: 'What is MiniMax?' });
console.log(response);
// Image generation
const image = await sdk.generateImage({ prompt: 'A cat in a spacesuit' });
console.log(image);
// Speech synthesis
await sdk.speech({ text: 'Hello!', out: 'hello.mp3' });
// Video generation (async)
const { taskId } = await sdk.generateVideo({ prompt: 'Ocean waves at sunset', async: true });
const task = await sdk.getVideoTask({ taskId });
// Music generation
const music = await sdk.generateMusic({ prompt: 'Upbeat pop', lyrics: '[verse] La da dee, sunny day' });
// Web search
const results = await sdk.search({ query: 'MiniMax AI latest news' });
// Image vision
const description = await sdk.describeImage({ image: 'photo.jpg' });
// Check quota
const quota = await sdk.getQuota();API Reference
new MiniMaxSDK(options)
Initialize the SDK with options:
const sdk = new MiniMaxSDK({
apiKey: 'sk-xxxxx', // Your API key
region: 'global', // 'global' or 'cn', auto-detected by default
baseUrl: '...', // Custom base URL (optional)
timeout: 60000, // Request timeout in ms (optional)
});sdk.chat(request)
Send a chat message with support for streaming and multi-turn conversations.
// Non-streaming
const response = await sdk.chat({ message: 'Hello!' });
// Streaming
const stream = await sdk.chat({ message: 'Hello!', stream: true });
for await (const event of stream) {
console.log(event);
}sdk.speech(request)
Synthesize speech from text.
// Non-streaming
await sdk.speech({ text: 'Hello!', out: 'hello.mp3' });
// Streaming
const stream = await sdk.speech({ text: 'Hello!', stream: true });
for await (const chunk of stream) {
// process audio chunks
}sdk.voices(language?)
Get available system voices.
const voices = await sdk.voices();
const chineseVoices = await sdk.voices('Chinese');sdk.generateImage(request)
Generate images from text prompts.
const image = await sdk.generateImage({
prompt: 'A cat in a spacesuit',
n: 3,
aspectRatio: '16:9',
});sdk.generateVideo(request)
Generate videos from text prompts.
// Async (returns task ID)
const { taskId } = await sdk.generateVideo({
prompt: 'Ocean waves at sunset',
async: true,
});
// Sync (waits for completion)
const video = await sdk.generateVideo({
prompt: 'A robot painting',
});sdk.getVideoTask({ taskId })
Get video generation task status.
const task = await sdk.getVideoTask({ taskId: '123456' });sdk.downloadVideo(request)
Download a generated video by file ID.
await sdk.downloadVideo({ fileId: '176844028768320', out: 'video.mp4' });sdk.generateMusic(request)
Generate music from text prompts.
// Non-streaming
const music = await sdk.generateMusic({
prompt: 'Upbeat pop',
lyrics: '[verse] La da dee, sunny day',
});
// Streaming
const stream = await sdk.generateMusic({ prompt: 'Jazz', stream: true });
for await (const chunk of stream) {
// process audio chunks
}sdk.search({ query })
Perform a web search.
const results = await sdk.search({ query: 'MiniMax AI latest news' });sdk.describeImage(request)
Describe or analyze an image.
const description = await sdk.describeImage({
image: 'photo.jpg', // file path, URL, or file ID
prompt: 'What breed is this cat?',
});sdk.getQuota()
Get your current API quota usage.
const quota = await sdk.getQuota();