content/providers/03-community-providers/28-minimax.mdx
vercel-minimax-ai-provider is a community provider that provides access to the latest MiniMax-M2 model from MiniMax.
API keys can be obtained from the MiniMax Platform.
The MiniMax provider is available via the vercel-minimax-ai-provider module. You can install it with:
<Tabs items={['pnpm', 'npm', 'yarn', 'bun']}> <Tab> <Snippet text="pnpm add vercel-minimax-ai-provider" dark /> </Tab> <Tab> <Snippet text="npm install vercel-minimax-ai-provider" dark /> </Tab> <Tab> <Snippet text="yarn add vercel-minimax-ai-provider" dark /> </Tab> <Tab> <Snippet text="bun add vercel-minimax-ai-provider" dark /> </Tab> </Tabs>
The MiniMax provider supports two API compatibility modes:
You can import the default provider instance minimax from vercel-minimax-ai-provider:
import { minimax } from 'vercel-minimax-ai-provider';
Or explicitly use the Anthropic-compatible instance:
import { minimaxAnthropic } from 'vercel-minimax-ai-provider';
Or OpenAI-compatible API format:
import { minimaxOpenAI } from 'vercel-minimax-ai-provider';
For custom configuration, you can use the createMinimax (Anthropic-compatible) or createMinimaxOpenAI (OpenAI-compatible) functions:
import { createMinimax } from 'vercel-minimax-ai-provider';
const minimax = createMinimax({
apiKey: process.env.MINIMAX_API_KEY,
});
You can use the following optional settings to customize the MiniMax provider instance:
baseURL string
Use a different URL prefix for API calls.
https://api.minimax.io/anthropic/v1https://api.minimax.io/v1apiKey string
API key that is being sent using the Authorization header. It defaults to
the MINIMAX_API_KEY environment variable.
headers Record<string,string>
Custom headers to include in the requests.
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation.
MiniMax provides two API formats. Both are included in this package.
The main difference is the API request/response format:
anthropic-version headerBoth formats access the same MiniMax models with the same capabilities.
| Model | Text Generation | Object Generation | Image Input | Tool Usage | Tool Streaming |
|---|---|---|---|---|---|
MiniMax-M2 | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
MiniMax-M2-Stable | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> | <Check size={18} /> | <Check size={18} /> |
import { minimax } from 'vercel-minimax-ai-provider';
import { generateText } from 'ai';
const result = await generateText({
model: minimax('MiniMax-M2'),
prompt: 'Explain quantum computing in simple terms.',
});
console.log(result.text);
import { minimax } from 'vercel-minimax-ai-provider';
import { streamText } from 'ai';
const result = streamText({
model: minimax('MiniMax-M2'),
prompt: 'Write a short story about a robot learning to paint.',
});
for await (const chunk of result.textStream) {
console.log(chunk);
}