Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 71 additions & 11 deletions packages/types/src/providers/minimax.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { ModelInfo } from "../model.js"

// Minimax
// https://platform.minimax.io/docs/guides/pricing
// https://platform.minimax.io/docs/api-reference/text-openai-api
// https://platform.minimax.io/docs/api-reference/text-anthropic-api
// https://platform.minimax.io/docs/guides/models-intro
// https://platform.minimax.io/docs/guides/pricing-paygo
// https://platform.minimax.io/docs/guides/pricing-tokenplan
export type MinimaxModelId = keyof typeof minimaxModels
export const minimaxDefaultModelId: MinimaxModelId = "MiniMax-M2.5"
export const minimaxDefaultModelId: MinimaxModelId = "MiniMax-M2.7"

export const minimaxModels = {
"MiniMax-M2.5": {
Expand All @@ -21,11 +21,56 @@ export const minimaxModels = {
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.03,
description:
"MiniMax M2.5, the latest MiniMax model with enhanced coding and agentic capabilities, building on the strengths of the M2 series.",
"MiniMax M2.5, the latest MiniMax model with enhanced coding and agentic capabilities, building on the strengths of the M2 series. See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2.5-highspeed": {
maxTokens: 16_384,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
excludedTools: ["apply_diff"],
preserveReasoning: true,
inputPrice: 0.6,
outputPrice: 2.4,
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.03,
description:
"MiniMax M2.5 highspeed: same performance as M2.5 but with faster response (approximately 100 tps vs 60 tps). See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Requires TokenPlan High-Speed subscription for use with TokenPlan keys. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2.7": {
maxTokens: 16_384,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
excludedTools: ["apply_diff"],
preserveReasoning: true,
inputPrice: 0.3,
outputPrice: 1.2,
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.06,
description:
"MiniMax M2.7, the latest MiniMax model with recursive self-improvement capabilities. See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2.7-highspeed": {
maxTokens: 16_384,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
excludedTools: ["apply_diff"],
preserveReasoning: true,
inputPrice: 0.6,
outputPrice: 2.4,
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.06,
description:
"MiniMax M2.7 highspeed: same performance as M2.7 but with faster response (approximately 100 tps vs 60 tps). See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Requires TokenPlan High-Speed subscription for use with TokenPlan keys. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2": {
maxTokens: 16_384,
contextWindow: 192_000,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
Expand All @@ -36,11 +81,11 @@ export const minimaxModels = {
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.03,
description:
"MiniMax M2, a model born for Agents and code, featuring Top-tier Coding Capabilities, Powerful Agentic Performance, and Ultimate Cost-Effectiveness & Speed.",
"MiniMax M2, a model born for Agents and code, featuring Top-tier Coding Capabilities, Powerful Agentic Performance, and Ultimate Cost-Effectiveness & Speed. See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2-Stable": {
maxTokens: 16_384,
contextWindow: 192_000,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
Expand All @@ -51,11 +96,11 @@ export const minimaxModels = {
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.03,
description:
"MiniMax M2 Stable (High Concurrency, Commercial Use), a model born for Agents and code, featuring Top-tier Coding Capabilities, Powerful Agentic Performance, and Ultimate Cost-Effectiveness & Speed.",
"MiniMax M2 Stable (High Concurrency, Commercial Use), a model born for Agents and code, featuring Top-tier Coding Capabilities, Powerful Agentic Performance, and Ultimate Cost-Effectiveness & Speed. See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2.1": {
maxTokens: 16_384,
contextWindow: 192_000,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
Expand All @@ -66,7 +111,22 @@ export const minimaxModels = {
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.03,
description:
"MiniMax M2.1 builds on M2 with improved overall performance for agentic coding tasks and significantly faster response times.",
"MiniMax M2.1 builds on M2 with improved overall performance for agentic coding tasks and significantly faster response times. See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Note: When using TokenPlan, usage is billed per request, not per token.",
},
"MiniMax-M2.1-highspeed": {
maxTokens: 16_384,
contextWindow: 204_800,
supportsImages: false,
supportsPromptCache: true,
includedTools: ["search_and_replace"],
excludedTools: ["apply_diff"],
preserveReasoning: true,
inputPrice: 0.6,
outputPrice: 2.4,
cacheWritesPrice: 0.375,
cacheReadsPrice: 0.03,
description:
"MiniMax M2.1 highspeed: same performance as M2.1 but with faster response (approximately 100 tps vs 60 tps). See pricing at https://platform.minimax.io/docs/guides/pricing-paygo. Requires TokenPlan High-Speed subscription for use with TokenPlan keys. Note: When using TokenPlan, usage is billed per request, not per token.",
},
} as const satisfies Record<string, ModelInfo>

Expand Down
70 changes: 64 additions & 6 deletions src/api/providers/__tests__/minimax.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ describe("MiniMaxHandler", () => {
const model = handlerWithModel.getModel()
expect(model.id).toBe(testModelId)
expect(model.info).toEqual(minimaxModels[testModelId])
expect(model.info.contextWindow).toBe(192_000)
expect(model.info.contextWindow).toBe(204_800)
expect(model.info.maxTokens).toBe(16_384)
expect(model.info.supportsPromptCache).toBe(true)
expect(model.info.cacheWritesPrice).toBe(0.375)
Expand All @@ -128,7 +128,7 @@ describe("MiniMaxHandler", () => {
const model = handlerWithModel.getModel()
expect(model.id).toBe(testModelId)
expect(model.info).toEqual(minimaxModels[testModelId])
expect(model.info.contextWindow).toBe(192_000)
expect(model.info.contextWindow).toBe(204_800)
expect(model.info.maxTokens).toBe(16_384)
expect(model.info.supportsPromptCache).toBe(true)
expect(model.info.cacheWritesPrice).toBe(0.375)
Expand Down Expand Up @@ -191,10 +191,10 @@ describe("MiniMaxHandler", () => {
expect(model.info).toEqual(minimaxModels[minimaxDefaultModelId])
})

it("should default to MiniMax-M2.5 model", () => {
it("should default to MiniMax-M2.7 model", () => {
const handlerDefault = new MiniMaxHandler({ minimaxApiKey: "test-minimax-api-key" })
const model = handlerDefault.getModel()
expect(model.id).toBe("MiniMax-M2.5")
expect(model.id).toBe("MiniMax-M2.7")
})
})

Expand Down Expand Up @@ -399,7 +399,7 @@ describe("MiniMaxHandler", () => {
it("should correctly configure MiniMax-M2 model properties", () => {
const model = minimaxModels["MiniMax-M2"]
expect(model.maxTokens).toBe(16_384)
expect(model.contextWindow).toBe(192_000)
expect(model.contextWindow).toBe(204_800)
expect(model.supportsImages).toBe(false)
expect(model.supportsPromptCache).toBe(true)
expect(model.inputPrice).toBe(0.3)
Expand All @@ -411,13 +411,71 @@ describe("MiniMaxHandler", () => {
it("should correctly configure MiniMax-M2-Stable model properties", () => {
const model = minimaxModels["MiniMax-M2-Stable"]
expect(model.maxTokens).toBe(16_384)
expect(model.contextWindow).toBe(192_000)
expect(model.contextWindow).toBe(204_800)
expect(model.supportsImages).toBe(false)
expect(model.supportsPromptCache).toBe(true)
expect(model.inputPrice).toBe(0.3)
expect(model.outputPrice).toBe(1.2)
expect(model.cacheWritesPrice).toBe(0.375)
expect(model.cacheReadsPrice).toBe(0.03)
})

it("should correctly configure MiniMax-M2.7 model properties", () => {
const model = minimaxModels["MiniMax-M2.7"]
expect(model.maxTokens).toBe(16_384)
expect(model.contextWindow).toBe(204_800)
expect(model.supportsImages).toBe(false)
expect(model.supportsPromptCache).toBe(true)
expect(model.inputPrice).toBe(0.3)
expect(model.outputPrice).toBe(1.2)
expect(model.cacheWritesPrice).toBe(0.375)
expect(model.cacheReadsPrice).toBe(0.06)
})

it("should correctly configure MiniMax-M2.7-highspeed model properties", () => {
const model = minimaxModels["MiniMax-M2.7-highspeed"]
expect(model.maxTokens).toBe(16_384)
expect(model.contextWindow).toBe(204_800)
expect(model.supportsImages).toBe(false)
expect(model.supportsPromptCache).toBe(true)
expect(model.inputPrice).toBe(0.6)
expect(model.outputPrice).toBe(2.4)
expect(model.cacheWritesPrice).toBe(0.375)
expect(model.cacheReadsPrice).toBe(0.06)
})

it("should correctly configure MiniMax-M2.5-highspeed model properties", () => {
const model = minimaxModels["MiniMax-M2.5-highspeed"]
expect(model.maxTokens).toBe(16_384)
expect(model.contextWindow).toBe(204_800)
expect(model.supportsImages).toBe(false)
expect(model.supportsPromptCache).toBe(true)
expect(model.inputPrice).toBe(0.6)
expect(model.outputPrice).toBe(2.4)
expect(model.cacheWritesPrice).toBe(0.375)
expect(model.cacheReadsPrice).toBe(0.03)
})

it("should correctly configure MiniMax-M2.1-highspeed model properties", () => {
const model = minimaxModels["MiniMax-M2.1-highspeed"]
expect(model.maxTokens).toBe(16_384)
expect(model.contextWindow).toBe(204_800)
expect(model.supportsImages).toBe(false)
expect(model.supportsPromptCache).toBe(true)
expect(model.inputPrice).toBe(0.6)
expect(model.outputPrice).toBe(2.4)
expect(model.cacheWritesPrice).toBe(0.375)
expect(model.cacheReadsPrice).toBe(0.03)
})

it("should correctly configure MiniMax-M2.1 model properties with updated context window", () => {
const model = minimaxModels["MiniMax-M2.1"]
expect(model.contextWindow).toBe(204_800)
})

it("should correctly configure MiniMax-M2 model properties with updated context window", () => {
const model = minimaxModels["MiniMax-M2"]
expect(model.contextWindow).toBe(204_800)
})
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
BEDROCK_1M_CONTEXT_MODEL_IDS,
litellmDefaultModelInfo,
openAiModelInfoSaneDefaults,
minimaxDefaultModelId,
minimaxModels,
} from "@roo-code/types"

import { useSelectedModel } from "../useSelectedModel"
Expand Down Expand Up @@ -725,4 +727,51 @@ describe("useSelectedModel", () => {
expect(result.current.info).toEqual(customModelInfo)
})
})

describe("minimax provider", () => {
beforeEach(() => {
mockUseRouterModels.mockReturnValue({
data: {
openrouter: {},
requesty: {},
litellm: {},
},
isLoading: false,
isError: false,
} as any)

mockUseOpenRouterModelProviders.mockReturnValue({
data: {},
isLoading: false,
isError: false,
} as any)
})

it("should return default minimax model when no custom model is specified", () => {
const apiConfiguration: ProviderSettings = {
apiProvider: "minimax",
}

const wrapper = createWrapper()
const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })

expect(result.current.provider).toBe("minimax")
expect(result.current.id).toBe(minimaxDefaultModelId)
expect(result.current.info).toEqual(minimaxModels[minimaxDefaultModelId])
})

it("should use custom model ID and info when model exists in minimaxModels", () => {
const apiConfiguration: ProviderSettings = {
apiProvider: "minimax",
apiModelId: "MiniMax-M2.7",
}

const wrapper = createWrapper()
const { result } = renderHook(() => useSelectedModel(apiConfiguration), { wrapper })

expect(result.current.provider).toBe("minimax")
expect(result.current.id).toBe("MiniMax-M2.7")
expect(result.current.info).toEqual(minimaxModels["MiniMax-M2.7"])
})
})
})
Loading