Skip to content

Commit 414345c

Browse files
Maosghoulxiaosemrubens
authored
Feat: Add Minimax Provider (fixes #8818) (#8820)
Co-authored-by: xiaose <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
1 parent f839d4c commit 414345c

File tree

31 files changed

+568
-0
lines changed

31 files changed

+568
-0
lines changed

packages/types/src/global-settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ export const SECRET_STATE_KEYS = [
218218
"doubaoApiKey",
219219
"moonshotApiKey",
220220
"mistralApiKey",
221+
"minimaxApiKey",
221222
"unboundApiKey",
222223
"requestyApiKey",
223224
"xaiApiKey",

packages/types/src/provider-settings.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
vscodeLlmModels,
2525
xaiModels,
2626
internationalZAiModels,
27+
minimaxModels,
2728
} from "./providers/index.js"
2829

2930
/**
@@ -131,6 +132,7 @@ export const providerNames = [
131132
"groq",
132133
"mistral",
133134
"moonshot",
135+
"minimax",
134136
"openai-native",
135137
"qwen-code",
136138
"roo",
@@ -327,6 +329,13 @@ const moonshotSchema = apiModelIdProviderModelSchema.extend({
327329
moonshotApiKey: z.string().optional(),
328330
})
329331

332+
const minimaxSchema = apiModelIdProviderModelSchema.extend({
333+
minimaxBaseUrl: z
334+
.union([z.literal("https://api.minimax.io/v1"), z.literal("https://api.minimaxi.com/v1")])
335+
.optional(),
336+
minimaxApiKey: z.string().optional(),
337+
})
338+
330339
const unboundSchema = baseProviderSettingsSchema.extend({
331340
unboundApiKey: z.string().optional(),
332341
unboundModelId: z.string().optional(),
@@ -435,6 +444,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
435444
deepInfraSchema.merge(z.object({ apiProvider: z.literal("deepinfra") })),
436445
doubaoSchema.merge(z.object({ apiProvider: z.literal("doubao") })),
437446
moonshotSchema.merge(z.object({ apiProvider: z.literal("moonshot") })),
447+
minimaxSchema.merge(z.object({ apiProvider: z.literal("minimax") })),
438448
unboundSchema.merge(z.object({ apiProvider: z.literal("unbound") })),
439449
requestySchema.merge(z.object({ apiProvider: z.literal("requesty") })),
440450
humanRelaySchema.merge(z.object({ apiProvider: z.literal("human-relay") })),
@@ -476,6 +486,7 @@ export const providerSettingsSchema = z.object({
476486
...deepInfraSchema.shape,
477487
...doubaoSchema.shape,
478488
...moonshotSchema.shape,
489+
...minimaxSchema.shape,
479490
...unboundSchema.shape,
480491
...requestySchema.shape,
481492
...humanRelaySchema.shape,
@@ -560,6 +571,7 @@ export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
560571
"gemini-cli": "apiModelId",
561572
mistral: "apiModelId",
562573
moonshot: "apiModelId",
574+
minimax: "apiModelId",
563575
deepseek: "apiModelId",
564576
deepinfra: "deepInfraModelId",
565577
doubao: "apiModelId",
@@ -676,6 +688,11 @@ export const MODELS_BY_PROVIDER: Record<
676688
label: "Moonshot",
677689
models: Object.keys(moonshotModels),
678690
},
691+
minimax: {
692+
id: "minimax",
693+
label: "MiniMax",
694+
models: Object.keys(minimaxModels),
695+
},
679696
"openai-native": {
680697
id: "openai-native",
681698
label: "OpenAI",

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ export * from "./xai.js"
3030
export * from "./vercel-ai-gateway.js"
3131
export * from "./zai.js"
3232
export * from "./deepinfra.js"
33+
export * from "./minimax.js"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import type { ModelInfo } from "../model.js"
2+
3+
// Minimax
4+
// https://www.minimax.io/platform/document/text_api_intro
5+
// https://www.minimax.io/platform/document/pricing
6+
export type MinimaxModelId = keyof typeof minimaxModels
7+
export const minimaxDefaultModelId: MinimaxModelId = "MiniMax-M2"
8+
9+
export const minimaxModels = {
10+
"MiniMax-M2": {
11+
maxTokens: 16_384,
12+
contextWindow: 192_000,
13+
supportsImages: false,
14+
supportsPromptCache: false,
15+
inputPrice: 0.3,
16+
outputPrice: 1.2,
17+
cacheWritesPrice: 0,
18+
cacheReadsPrice: 0,
19+
description:
20+
"MiniMax M2, a model born for Agents and code, featuring Top-tier Coding Capabilities, Powerful Agentic Performance, and Ultimate Cost-Effectiveness & Speed.",
21+
},
22+
} as const satisfies Record<string, ModelInfo>
23+
24+
export const MINIMAX_DEFAULT_TEMPERATURE = 1.0

src/api/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
FeatherlessHandler,
4141
VercelAiGatewayHandler,
4242
DeepInfraHandler,
43+
MiniMaxHandler,
4344
} from "./providers"
4445
import { NativeOllamaHandler } from "./providers/native-ollama"
4546

@@ -165,6 +166,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
165166
return new FeatherlessHandler(options)
166167
case "vercel-ai-gateway":
167168
return new VercelAiGatewayHandler(options)
169+
case "minimax":
170+
return new MiniMaxHandler(options)
168171
default:
169172
apiProvider satisfies "gemini-cli" | undefined
170173
return new AnthropicHandler(options)

0 commit comments

Comments
 (0)