Files
intelligence-terminal/lib/llm/minimax.mjs
Octopus 6f41c2ff3d 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
2026-03-16 08:45:35 -05:00

52 lines
1.4 KiB
JavaScript

// 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,
};
}
}