Skip to content

Commit 608fee3

Browse files
Maosghoulxiaosemrubens
authored andcommitted
Feat: Add Minimax Provider (fixes RooCodeInc#8818) (RooCodeInc#8820)
Co-authored-by: xiaose <[email protected]> Co-authored-by: Matt Rubens <[email protected]>
1 parent 0fd4bc4 commit 608fee3

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
/**
@@ -132,6 +133,7 @@ export const providerNames = [
132133
"groq",
133134
"mistral",
134135
"moonshot",
136+
"minimax",
135137
"openai-native",
136138
"qwen-code",
137139
"roo",
@@ -328,6 +330,13 @@ const moonshotSchema = apiModelIdProviderModelSchema.extend({
328330
moonshotApiKey: z.string().optional(),
329331
})
330332

333+
const minimaxSchema = apiModelIdProviderModelSchema.extend({
334+
minimaxBaseUrl: z
335+
.union([z.literal("https://api.minimax.io/v1"), z.literal("https://api.minimaxi.com/v1")])
336+
.optional(),
337+
minimaxApiKey: z.string().optional(),
338+
})
339+
331340
const unboundSchema = baseProviderSettingsSchema.extend({
332341
unboundApiKey: z.string().optional(),
333342
unboundModelId: z.string().optional(),
@@ -448,6 +457,7 @@ export const providerSettingsSchemaDiscriminated = z.discriminatedUnion("apiProv
448457
deepInfraSchema.merge(z.object({ apiProvider: z.literal("deepinfra") })),
449458
doubaoSchema.merge(z.object({ apiProvider: z.literal("doubao") })),
450459
moonshotSchema.merge(z.object({ apiProvider: z.literal("moonshot") })),
460+
minimaxSchema.merge(z.object({ apiProvider: z.literal("minimax") })),
451461
unboundSchema.merge(z.object({ apiProvider: z.literal("unbound") })),
452462
requestySchema.merge(z.object({ apiProvider: z.literal("requesty") })),
453463
humanRelaySchema.merge(z.object({ apiProvider: z.literal("human-relay") })),
@@ -490,6 +500,7 @@ export const providerSettingsSchema = z.object({
490500
...deepInfraSchema.shape,
491501
...doubaoSchema.shape,
492502
...moonshotSchema.shape,
503+
...minimaxSchema.shape,
493504
...unboundSchema.shape,
494505
...requestySchema.shape,
495506
...humanRelaySchema.shape,
@@ -576,6 +587,7 @@ export const modelIdKeysByProvider: Record<TypicalProvider, ModelIdKey> = {
576587
"gemini-cli": "apiModelId",
577588
mistral: "apiModelId",
578589
moonshot: "apiModelId",
590+
minimax: "apiModelId",
579591
deepseek: "apiModelId",
580592
deepinfra: "deepInfraModelId",
581593
doubao: "apiModelId",
@@ -693,6 +705,11 @@ export const MODELS_BY_PROVIDER: Record<
693705
label: "Moonshot",
694706
models: Object.keys(moonshotModels),
695707
},
708+
minimax: {
709+
id: "minimax",
710+
label: "MiniMax",
711+
models: Object.keys(minimaxModels),
712+
},
696713
"openai-native": {
697714
id: "openai-native",
698715
label: "OpenAI",

packages/types/src/providers/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ 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"
3334
export * from "./ibm-watsonx.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
WatsonxAIHandler,
4445
} from "./providers"
4546
import { NativeOllamaHandler } from "./providers/native-ollama"
@@ -166,6 +167,8 @@ export function buildApiHandler(configuration: ProviderSettings): ApiHandler {
166167
return new FeatherlessHandler(options)
167168
case "vercel-ai-gateway":
168169
return new VercelAiGatewayHandler(options)
170+
case "minimax":
171+
return new MiniMaxHandler(options)
169172
case "ibm-watsonx":
170173
return new WatsonxAIHandler(options)
171174
default:

0 commit comments

Comments
 (0)