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
20 changes: 18 additions & 2 deletions README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ node package/cli.js -r <session-id>

### Configure MiniMax

MiniMax can be selected directly through the built-in provider registry. The default region is `global_en`; use `cn_zh` for the China endpoint.
MiniMax can be selected directly through the built-in provider registry. The default model is `MiniMax-M3.1-Flash`. The default region is `global_en`; use `cn_zh` for the China endpoint.

```json
{
Expand All @@ -230,10 +230,26 @@ MiniMax can be selected directly through the built-in provider registry. The def
Run either registered model explicitly when needed:

```bash
node package/cli.js --settings settings.json --model MiniMax-M3.1-Flash
node package/cli.js --settings settings.json --model MiniMax-M3
node package/cli.js --settings settings.json --model MiniMax-M2.7
```

Both models have a 1,000,000-token context window and accept text, image, and video input. MiniMax-M3.1-Flash always uses adaptive thinking; disabling it is not supported. Its `output_config.effort` accepts `low`, `medium`, `high`, `xhigh`, and `max` (default). For example, select `xhigh` with `CLAUDE_CODE_EXTRA_BODY='{"output_config":{"effort":"xhigh"}}'`. `none` is invalid. Flash does not support `service_tier`, so this client omits that field for Flash requests.

MiniMax-M3 supports adaptive or disabled thinking, defaults to disabled for this Messages client, and ignores effort. Its OpenAI-compatible API defaults to adaptive thinking; that API uses `reasoning_effort` for Flash instead of `output_config.effort`.

Prices below are USD per million tokens (input / output / cache read); cache-write prices are unknown:

| Model | Standard pricing |
| --- | --- |
| MiniMax-M3.1-Flash | $0.15 / $0.60 / $0.015 |
| MiniMax-M3, request input ≤512k | $0.30 / $1.20 / $0.06 |
| MiniMax-M3, request input >512k | $0.60 / $2.40 / $0.12 |

MiniMax-M3 Priority costs 1.5× the Standard rates. The estimator retains its existing 512,000-token boundary; the official pricing page publishes `512k` without an integer expansion. No model-specific output limit is assumed.

Sources: [models](https://platform.minimax.io/docs/guides/models-intro.md), [pricing](https://platform.minimax.io/docs/pricing/overview.md), [Messages API](https://platform.minimax.io/docs/api-reference/text-chat-anthropic.md), [OpenAI-compatible API](https://platform.minimax.io/docs/api-reference/text-chat-openai.md).

| Region | Anthropic-compatible base URL | OpenAI-compatible base URL | Documentation |
| --- | --- | --- | --- |
| `global_en` | `https://api.minimax.io/anthropic` | `https://api.minimax.io/v1` | `https://platform.minimax.io/docs` |
Expand Down
9 changes: 8 additions & 1 deletion src/services/api/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import type { TextBlockParam } from '@anthropic-ai/sdk/resources/index.mjs'
import type { Stream } from '@anthropic-ai/sdk/streaming.mjs'
import { randomUUID } from 'crypto'
import {
configureMiniMaxRequest,
getAPIProvider,
getMiniMaxModel,
isFirstPartyAnthropicBaseUrl,
} from 'src/utils/model/providers.js'
import {
Expand Down Expand Up @@ -445,6 +447,9 @@ function configureEffortParams(
betas: string[],
model: string,
): void {
// MiniMax effort is validated after custom output_config parameters are merged.
if (getMiniMaxModel(model)) return

if (!modelSupportsEffort(model) || 'effort' in outputConfig) {
return
}
Expand Down Expand Up @@ -1703,7 +1708,7 @@ async function* queryModel(

lastRequestBetas = betasParams

return {
const params = {
model: normalizeModelStringForAPI(options.model),
messages: addCacheBreakpoints(
messagesForAPI,
Expand Down Expand Up @@ -1733,6 +1738,8 @@ async function* queryModel(
}),
...(speed !== undefined && { speed }),
}
configureMiniMaxRequest(options.model, params, effort)
return params
}

// Compute log scalars synchronously so the fire-and-forget .then() closure
Expand Down
91 changes: 91 additions & 0 deletions src/utils/__tests__/minimax.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
import { test } from 'node:test'
import assert from 'node:assert/strict'
import {
configureMiniMaxRequest,
getMiniMaxModel,
getMiniMaxPricing,
MINIMAX_MODELS,
} from '../model/providers.js'
import { ALL_MODEL_CONFIGS } from '../model/configs.js'

const flash = 'MiniMax-M3.1-Flash'

test('MiniMax catalog and defaults contain only the current models', () => {
assert.deepEqual(MINIMAX_MODELS.map(model => model.modelId), [flash, 'MiniMax-M3'])
assert.equal(getMiniMaxModel(flash.toLowerCase())?.modelId, flash)
assert.equal(getMiniMaxModel('MiniMax-M2.7'), undefined)
for (const model of MINIMAX_MODELS) {
assert.equal(model.contextWindow, 1_000_000)
assert.deepEqual(model.inputModalities, ['text', 'image', 'video'])
assert.equal(model.pricingUsdPerMillionTokens.cacheWrite, null)
}
for (const config of Object.values(ALL_MODEL_CONFIGS)) {
assert.equal(config.minimax, flash)
}
})

test('MiniMax-M3 pricing selects context and service tiers at the boundary', () => {
for (const tokens of [0, 511_999, 512_000, 512_001, 1_000_000]) {
const longContext = tokens > 512_000
for (const tier of ['standard', 'priority', undefined]) {
const expected = tier === 'priority'
? (longContext ? [0.9, 3.6, 0.18] : [0.45, 1.8, 0.09])
: (longContext ? [0.6, 2.4, 0.12] : [0.3, 1.2, 0.06])
const pricing = getMiniMaxPricing('MiniMax-M3', tokens, tier)!
assert.deepEqual([pricing.input, pricing.output, pricing.cacheRead], expected)
assert.equal(pricing.cacheWrite, null)
}
}
})

test('Flash pricing stays flat and unknown models retain generic pricing fallback', () => {
for (const tokens of [0, 512_000, 512_001, 1_000_000]) {
assert.deepEqual(getMiniMaxPricing(flash, tokens), {
input: 0.15, output: 0.6, cacheRead: 0.015, cacheWrite: null,
})
}
assert.equal(getMiniMaxPricing('custom-model'), undefined)
})

test('Flash enforces adaptive thinking and omits unsupported service tier', () => {
for (const thinking of [undefined, { type: 'disabled' }, { type: 'enabled', budget_tokens: 1000 }]) {
const params: Record<string, unknown> = { thinking, service_tier: 'priority', max_tokens: 1234 }
configureMiniMaxRequest(flash, params, undefined)
assert.deepEqual(params.thinking, { type: 'adaptive' })
assert.deepEqual(params.output_config, { effort: 'max' })
assert.equal('service_tier' in params, false)
assert.equal(params.max_tokens, 1234)
}
})

test('Flash supports every published effort and preserves output format', () => {
for (const effort of ['low', 'medium', 'high', 'xhigh', 'max']) {
const format = { type: 'json_schema' }
const params: Record<string, unknown> = { output_config: { effort, format } }
configureMiniMaxRequest(flash, params, 'low')
assert.deepEqual(params.output_config, { effort, format })
const fromSetting: Record<string, unknown> = {}
configureMiniMaxRequest(flash, fromSetting, effort)
assert.deepEqual(fromSetting.output_config, { effort })
}
for (const effort of ['none', 'invalid', 42]) {
assert.throws(() => configureMiniMaxRequest(flash, { output_config: { effort } }, undefined), /Unsupported effort/)
}
})

test('MiniMax-M3 defaults thinking off, supports adaptive, and ignores effort', () => {
for (const thinking of [undefined, { type: 'disabled' }, { type: 'enabled', budget_tokens: 1000 }, { type: 'adaptive' }]) {
const params: Record<string, unknown> = { thinking, output_config: { effort: 'max' }, service_tier: 'priority' }
configureMiniMaxRequest('MiniMax-M3', params, 'low')
assert.deepEqual(params.thinking, { type: thinking && thinking.type !== 'disabled' ? 'adaptive' : 'disabled' })
assert.equal('output_config' in params, false)
assert.equal(params.service_tier, 'priority')
}
})

test('Custom model request parameters pass through unchanged', () => {
const params = { thinking: { type: 'enabled' }, output_config: { effort: 'custom' }, service_tier: 'priority' }
const original = structuredClone(params)
configureMiniMaxRequest('custom-model', params, undefined)
assert.deepEqual(params, original)
})
11 changes: 10 additions & 1 deletion src/utils/effort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { isUltrathinkEnabled } from './thinking.js'
import { getInitialSettings } from './settings/settings.js'
import { isProSubscriber, isMaxSubscriber, isTeamSubscriber } from './auth.js'
import { getFeatureValue_CACHED_MAY_BE_STALE } from 'src/services/analytics/growthbook.js'
import { getAPIProvider } from './model/providers.js'
import { getAPIProvider, getMiniMaxModel } from './model/providers.js'
import { get3PModelCapabilityOverride } from './model/modelSupportOverrides.js'
import { isEnvTruthy } from './envUtils.js'
import type { EffortLevel } from 'src/entrypoints/sdk/runtimeTypes.js'
Expand All @@ -21,6 +21,9 @@ export type EffortValue = EffortLevel | number

// @[MODEL LAUNCH]: Add the new model to the allowlist if it supports the effort parameter.
export function modelSupportsEffort(model: string): boolean {
const miniMaxModel = getMiniMaxModel(model)
if (miniMaxModel) return miniMaxModel.reasoningEfforts.length > 0

const m = model.toLowerCase()
if (isEnvTruthy(process.env.CLAUDE_CODE_ALWAYS_ENABLE_EFFORT)) {
return true
Expand Down Expand Up @@ -51,6 +54,9 @@ export function modelSupportsEffort(model: string): boolean {
// @[MODEL LAUNCH]: Add the new model to the allowlist if it supports 'max' effort.
// Per API docs, 'max' is Opus 4.6 only for public models — other models return an error.
export function modelSupportsMaxEffort(model: string): boolean {
const miniMaxModel = getMiniMaxModel(model)
if (miniMaxModel) return miniMaxModel.defaultEffort === 'max'

const supported3P = get3PModelCapabilityOverride(model, 'max_effort')
if (supported3P !== undefined) {
return supported3P
Expand Down Expand Up @@ -279,6 +285,9 @@ export function getOpusDefaultEffortConfig(): OpusDefaultEffortConfig {
export function getDefaultEffortForModel(
model: string,
): EffortValue | undefined {
const miniMaxModel = getMiniMaxModel(model)
if (miniMaxModel) return miniMaxModel.defaultEffort

if (process.env.USER_TYPE === 'ant') {
const config = getAntModelOverrideConfig()
const isDefaultModel =
Expand Down
22 changes: 11 additions & 11 deletions src/utils/model/configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,87 +11,87 @@ export const CLAUDE_3_7_SONNET_CONFIG = {
bedrock: 'us.anthropic.claude-3-7-sonnet-20250219-v1:0',
vertex: 'claude-3-7-sonnet@20250219',
foundry: 'claude-3-7-sonnet',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_3_5_V2_SONNET_CONFIG = {
firstParty: 'claude-3-5-sonnet-20241022',
bedrock: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
vertex: 'claude-3-5-sonnet-v2@20241022',
foundry: 'claude-3-5-sonnet',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_3_5_HAIKU_CONFIG = {
firstParty: 'claude-3-5-haiku-20241022',
bedrock: 'us.anthropic.claude-3-5-haiku-20241022-v1:0',
vertex: 'claude-3-5-haiku@20241022',
foundry: 'claude-3-5-haiku',
minimax: 'MiniMax-M2.7',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_HAIKU_4_5_CONFIG = {
firstParty: 'claude-haiku-4-5-20251001',
bedrock: 'us.anthropic.claude-haiku-4-5-20251001-v1:0',
vertex: 'claude-haiku-4-5@20251001',
foundry: 'claude-haiku-4-5',
minimax: 'MiniMax-M2.7',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_SONNET_4_CONFIG = {
firstParty: 'claude-sonnet-4-20250514',
bedrock: 'us.anthropic.claude-sonnet-4-20250514-v1:0',
vertex: 'claude-sonnet-4@20250514',
foundry: 'claude-sonnet-4',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_SONNET_4_5_CONFIG = {
firstParty: 'claude-sonnet-4-5-20250929',
bedrock: 'us.anthropic.claude-sonnet-4-5-20250929-v1:0',
vertex: 'claude-sonnet-4-5@20250929',
foundry: 'claude-sonnet-4-5',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_OPUS_4_CONFIG = {
firstParty: 'claude-opus-4-20250514',
bedrock: 'us.anthropic.claude-opus-4-20250514-v1:0',
vertex: 'claude-opus-4@20250514',
foundry: 'claude-opus-4',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_OPUS_4_1_CONFIG = {
firstParty: 'claude-opus-4-1-20250805',
bedrock: 'us.anthropic.claude-opus-4-1-20250805-v1:0',
vertex: 'claude-opus-4-1@20250805',
foundry: 'claude-opus-4-1',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_OPUS_4_5_CONFIG = {
firstParty: 'claude-opus-4-5-20251101',
bedrock: 'us.anthropic.claude-opus-4-5-20251101-v1:0',
vertex: 'claude-opus-4-5@20251101',
foundry: 'claude-opus-4-5',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_OPUS_4_6_CONFIG = {
firstParty: 'claude-opus-4-6',
bedrock: 'us.anthropic.claude-opus-4-6-v1',
vertex: 'claude-opus-4-6',
foundry: 'claude-opus-4-6',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

export const CLAUDE_SONNET_4_6_CONFIG = {
firstParty: 'claude-sonnet-4-6',
bedrock: 'us.anthropic.claude-sonnet-4-6',
vertex: 'claude-sonnet-4-6',
foundry: 'claude-sonnet-4-6',
minimax: 'MiniMax-M3',
minimax: 'MiniMax-M3.1-Flash',
} as const satisfies ModelConfig

// @[MODEL LAUNCH]: Register the new config here.
Expand Down
Loading
Loading