MiniMax Provider
The MiniMax provider offers access to the MiniMax-M series of language models through the MiniMax API, including models with reasoning capabilities, as well as video generation with the MiniMax-H series.
API keys can be obtained from the MiniMax Platform.
Setup
The MiniMax provider is available via the @ai-sdk/minimax module. You can install it with:
pnpm add @ai-sdk/minimax
Provider Instance
You can import the default provider instance minimax from @ai-sdk/minimax:
import { minimax } from '@ai-sdk/minimax';For custom configuration, you can import createMiniMax and create a provider instance with your settings:
import { createMiniMax } from '@ai-sdk/minimax';
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. This provider speaks MiniMax's Anthropic-compatible protocol, so the default prefix is
https://api.minimax.io/anthropic/v1— not the OpenAI-compatiblehttps://api.minimax.io/v1. -
videoBaseURL string
Use a different URL prefix for video generation API calls. The video API uses the MiniMax V2 native endpoint (not the Anthropic-compatible endpoint). The default prefix is
https://api.minimax.io. -
apiKey string
API key for the MiniMax API. It defaults to the
MINIMAX_API_KEYenvironment variable. Language models send it in thex-api-keyheader (the Anthropic-compatible protocol); video models send it asAuthorization: Bearer. -
headers Record<string,string>
Custom headers to include in the requests
-
fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>
Custom fetch implementation
Language Models
You can create language models using a provider instance:
import { minimax } from '@ai-sdk/minimax';import { generateText } from 'ai';
const { text } = await generateText({ model: minimax('minimax-m3'), prompt: 'Write a vegetarian lasagna recipe for 4 people.',});You can also use the .chat() or .languageModel() factory methods:
const model = minimax.chat('minimax-m3');// orconst model = minimax.languageModel('minimax-m3');MiniMax language models can be used in the streamText function
(see AI SDK Core).
Reasoning
MiniMax-M models can produce intermediate reasoning ("thinking") before their final response. You control this behavior through provider options. The reasoning output is streamed through the standard AI SDK reasoning parts.
import { minimax, type MiniMaxLanguageModelOptions } from '@ai-sdk/minimax';import { generateText } from 'ai';
const { text, reasoningText } = await generateText({ model: minimax('minimax-m3'), providerOptions: { minimax: { thinking: { type: 'adaptive' }, } satisfies MiniMaxLanguageModelOptions, }, prompt: 'How many "r"s are in the word "strawberry"?',});
console.log(reasoningText);console.log(text);See AI SDK UI: Chatbot for more details on how to integrate reasoning into your chatbot.
Provider Options
The following optional provider options are available for MiniMax language models:
-
thinking object
Controls the model's reasoning ("thinking") behavior.
- type 'adaptive' | 'disabled'
'adaptive': the model decides when to reason (deep reasoning enabled)'disabled': the model responds directly without reasoning, for higher throughput and lower latency
When omitted, the model uses its provider-side default.
Thinking control is only supported on
minimax-m3. The M2.x models always think, so'disabled'has no effect on them. - type 'adaptive' | 'disabled'
Video Models
You can generate videos with the MiniMax-H3 model using the
experimental_generateVideo
function:
import { minimax, type MiniMaxVideoModelOptions } from '@ai-sdk/minimax';import { experimental_generateVideo as generateVideo } from 'ai';
const { video } = await generateVideo({ model: minimax.video('MiniMax-H3'), prompt: 'A white kitten chases a butterfly across a sunlit garden.', aspectRatio: '16:9', duration: 5, providerOptions: { minimax: { pollTimeoutMs: 600000, // 10 minutes } satisfies MiniMaxVideoModelOptions, },});MiniMax-H3 generates one video per call. Generation is asynchronous — the model creates a task and polls until it completes, then returns the resulting MP4 URL.
duration accepts a whole number of seconds from 5 to 15, and defaults to 5. A
fractional value is rounded and an out-of-range value is clamped, each with a
warning. The only supported output resolution is 2K.
For text-to-video, aspectRatio defaults to 16:9 when omitted. The MiniMax
API requires a concrete ratio for text-only requests and does not accept
adaptive. For reference-to-video, the API default is adaptive when
aspectRatio is omitted. For image-to-video with frame images, the aspect
ratio follows the input image.
Result URLs are time-limited. Download and persist the video to your own storage promptly after generation.
Generation modes
The generation mode is inferred from the inputs you pass:
- Text-to-video —
promptonly. - First-frame image-to-video — pass
image(or aframeImagesentry withframeType: 'first_frame') to animate a starting image. - First-to-last keyframes — pass
frameImageswith both afirst_frameand alast_frameto control the transition. - Reference-to-video — pass
inputReferences(images and/or videos, routed by media type) to keep a subject/style or follow motion. Frame images and references are mutually exclusive.
When a frame image is supplied, the aspect ratio follows the image and any
explicit aspectRatio is ignored.
Video Provider Options
The following optional provider options are available for MiniMax video models:
-
resolution string
Output resolution. MiniMax-H3 currently only supports
'2K'(the default). -
ratio 'adaptive' | '21:9' | '16:9' | '4:3' | '1:1' | '3:4' | '9:16'
Aspect ratio of the generated video. Overrides the top-level
aspectRatio. -
referenceAudioUrls string[]
Reference audio URLs (or
mm_file://handles) for reference-to-video generation. Must be paired with at least one reference image or video. Up to 3. -
aigcWatermark boolean
Whether to embed an AIGC watermark in the output. Defaults to
false. -
pollIntervalMs number
Interval in milliseconds between task status polls. Default:
10000. -
pollTimeoutMs number
Maximum time in milliseconds to poll before timing out. Default:
600000.
MiniMax mm_file:// handles are only forwarded as-is for
referenceAudioUrls. They cannot be used for image, frameImages, or
inputReferences: those inputs go through the AI SDK's file handling, which
base64-decodes any string that is not an http(s):// or data: URL. Pass
those inputs as public URLs, data URIs, or binary data instead.
Video Provider Metadata
MiniMax video results include providerMetadata.minimax:
-
taskId string
ID of the MiniMax generation task.
-
videoUrl string
The MiniMax-hosted MP4 URL (the same URL as
video). Time-limited. -
resolvedInputs object
The inputs that were actually sent, after the caps and rejections H3 imposes (warnings report that an input was dropped, but not how many survived).
- imageCount number — number of images sent (frame images or reference images).
- referenceVideoUrls string[] — the URLs of the reference videos sent. Inline video data is omitted, since it is sent as a data URI.
-
duration number
Duration of the generated video in seconds, when reported by the API.
-
ratio string
Aspect ratio of the generated video, when reported by the API.
-
resolution string
Resolution tier of the generated video, when reported by the API.
-
usage object
Billed seconds, when reported by the API:
totalSeconds,inputSeconds, andoutputSeconds.
Model Capabilities
| Model | Image Input | Object Generation | Tool Usage | Tool Streaming |
|---|---|---|---|---|
minimax-m3 | ||||
minimax-m2.7 | ||||
minimax-m2.7-highspeed | ||||
minimax-m2.5 | ||||
minimax-m2.5-highspeed | ||||
minimax-m2.1 | ||||
minimax-m2.1-highspeed | ||||
minimax-m2 |
Please see the MiniMax docs for a full list of available models. You can also pass any available provider model ID as a string if needed.