abhigyanpatwari/GitNexus · error · Error
MiniMax API key is required but was not provided
Error message
MiniMax API key is required but was not provided
What it means
Thrown by createChatModel() in the 'minimax' provider branch when minimaxConfig.apiKey is falsy or whitespace-only. MiniMax is accessed through a ChatAnthropic wrapper pointed at the MiniMax Anthropic-compatible endpoint (MINIMAX_ANTHROPIC_BASE_URLS.global_en by default); the key is required to construct the client. After this guard, model capability/thinking-mode normalization proceeds.
Source
Thrown at gitnexus-web/src/core/llm/agent.ts:278
return new ChatOpenAI({
openAIApiKey: openRouterConfig.apiKey,
apiKey: openRouterConfig.apiKey, // Fallback for some versions
modelName: openRouterConfig.model,
temperature: openRouterConfig.temperature ?? 0.1,
maxTokens: openRouterConfig.maxTokens,
configuration: {
apiKey: openRouterConfig.apiKey, // Ensure client receives it
baseURL: openRouterConfig.baseUrl ?? DEFAULT_OPENROUTER_BASE_URL,
},
streaming: true,
});
}
case 'minimax': {
const minimaxConfig = config as MiniMaxConfig;
if (!minimaxConfig.apiKey || minimaxConfig.apiKey.trim() === '') {
throw new Error('MiniMax API key is required but was not provided');
}
const capabilities = getMiniMaxModelCapabilities(minimaxConfig.model);
const requestedThinkingMode = minimaxConfig.thinkingMode;
const thinkingMode: MiniMaxThinkingMode | undefined =
requestedThinkingMode && capabilities?.thinkingModes.includes(requestedThinkingMode)
? requestedThinkingMode
: (capabilities?.thinkingModes[0] ?? requestedThinkingMode);
const thinking =
thinkingMode && thinkingMode !== 'always_on' ? { type: thinkingMode } : undefined;
const temperature =
thinkingMode === 'adaptive' || thinkingMode === 'always_on'
? undefined
: (minimaxConfig.temperature ?? 0.1);
return new ChatAnthropic({
anthropicApiKey: minimaxConfig.apiKey,
model: minimaxConfig.model,View on GitHub (pinned to d540b00184)
Solutions
- Obtain a key from platform.minimax.io and enter it in provider settings
- Ensure the key is non-empty and non-whitespace
- If using the CN endpoint, set baseUrl to MINIMAX_ANTHROPIC_BASE_URLS.cn_zh
- Recreate the agent after setting the key (construction-time check)
Example fix
// before
createChatModel({ provider: 'minimax', apiKey: '', model: 'MiniMax-M3' }); // throws
// after
createChatModel({ provider: 'minimax', apiKey: userKey, model: 'MiniMax-M3' }); Defensive patterns
Strategy: validation
Validate before calling
function hasMiniMaxKey(cfg: { apiKey?: string }): boolean {
return typeof cfg.apiKey === 'string' && cfg.apiKey.trim().length > 0;
}
if (cfg.provider === 'minimax' && !hasMiniMaxKey(cfg)) {
throw new Error('Configure a MiniMax API key (from platform.minimax.io)');
} Type guard
function isMiniMaxConfigReady(cfg: unknown): cfg is { provider: 'minimax'; apiKey: string; model: string } {
return typeof cfg === 'object' && cfg !== null
&& (cfg as any).provider === 'minimax'
&& typeof (cfg as any).apiKey === 'string'
&& (cfg as any).apiKey.trim().length > 0;
} Try / catch
try {
createChatModel({ provider: 'minimax', apiKey, model });
} catch (e) {
if (e instanceof Error && /MiniMax API key is required/.test(e.message)) {
promptUserForKey('minimax');
return;
}
throw e;
} Prevention
- Obtain keys from platform.minimax.io (global) or platform.minimaxi.com (CN)
- Set baseUrl to MINIMAX_ANTHROPIC_BASE_URLS.cn_zh if using the CN endpoint
- Pick a supported model id from MINIMAX_MODEL_IDS so capability lookup succeeds
- Re-create the agent after entering the key (construction-time check)
When it happens
Trigger: Calling createChatModel({ provider: 'minimax', apiKey: undefined | '' | ' ', model: 'MiniMax-M3', ... }).
Common situations: The MiniMax key wasn't provisioned in settings; using a CN-region key against the global endpoint without setting baseUrl; switching to minimax provider without an account on platform.minimax.io.
Related errors
- OpenAI API key is required but was not provided
- OpenRouter API key is required but was not provided
- GLM API key is required but was not provided
- DeepSeek API key is required but was not provided
- Unsupported provider: ${(config as any).provider}
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/9679c34cf3f9f2ba.
Report an issue: GitHub.