feat: add MiniMax as LLM provider

Add MiniMax (api.minimax.io) as a fifth LLM provider option alongside
Anthropic, OpenAI, Gemini, and Codex. MiniMax offers an
OpenAI-compatible Chat Completions API with the M2.5 model (204K
context window).

Changes:
- lib/llm/minimax.mjs: new provider using raw fetch (no SDK)
- lib/llm/index.mjs: register MiniMax in the factory
- .env.example, crucix.config.mjs, README.md: document the new option
- test/llm-minimax.test.mjs: 10 unit tests (node:test)
- test/llm-minimax-integration.test.mjs: live API integration test

Usage:
  LLM_PROVIDER=minimax
  LLM_API_KEY=sk-...
  LLM_MODEL=MiniMax-M2.5          # optional, this is the default
This commit is contained in:
Octopus
2026-03-16 08:45:35 -05:00
parent 183702e688
commit 6f41c2ff3d
7 changed files with 239 additions and 8 deletions

View File

@@ -4,12 +4,14 @@ import { AnthropicProvider } from './anthropic.mjs';
import { OpenAIProvider } from './openai.mjs';
import { GeminiProvider } from './gemini.mjs';
import { CodexProvider } from './codex.mjs';
import { MiniMaxProvider } from './minimax.mjs';
export { LLMProvider } from './provider.mjs';
export { AnthropicProvider } from './anthropic.mjs';
export { OpenAIProvider } from './openai.mjs';
export { GeminiProvider } from './gemini.mjs';
export { CodexProvider } from './codex.mjs';
export { MiniMaxProvider } from './minimax.mjs';
/**
* Create an LLM provider based on config.
@@ -30,6 +32,8 @@ export function createLLMProvider(llmConfig) {
return new GeminiProvider({ apiKey, model });
case 'codex':
return new CodexProvider({ model });
case 'minimax':
return new MiniMaxProvider({ apiKey, model });
default:
console.warn(`[LLM] Unknown provider "${provider}". LLM features disabled.`);
return null;

51
lib/llm/minimax.mjs Normal file
View File

@@ -0,0 +1,51 @@
// MiniMax Provider — raw fetch, no SDK
// Uses MiniMax's OpenAI-compatible Chat Completions API
import { LLMProvider } from './provider.mjs';
export class MiniMaxProvider extends LLMProvider {
constructor(config) {
super(config);
this.name = 'minimax';
this.apiKey = config.apiKey;
this.model = config.model || 'MiniMax-M2.5';
}
get isConfigured() { return !!this.apiKey; }
async complete(systemPrompt, userMessage, opts = {}) {
const res = await fetch('https://api.minimax.io/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${this.apiKey}`,
},
body: JSON.stringify({
model: this.model,
max_tokens: opts.maxTokens || 4096,
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: userMessage },
],
}),
signal: AbortSignal.timeout(opts.timeout || 60000),
});
if (!res.ok) {
const err = await res.text().catch(() => '');
throw new Error(`MiniMax API ${res.status}: ${err.substring(0, 200)}`);
}
const data = await res.json();
const text = data.choices?.[0]?.message?.content || '';
return {
text,
usage: {
inputTokens: data.usage?.prompt_tokens || 0,
outputTokens: data.usage?.completion_tokens || 0,
},
model: data.model || this.model,
};
}
}