thedotmack/claude-mem · info
API key prompt cancelled — falling back to Claude provider.
Error message
API key prompt cancelled — falling back to Claude provider.
What it means
In the interactive provider flow for a non-Claude provider, cancelling the masked 'Paste your <provider> API key' prompt (Esc/Ctrl-C) hits this branch: the installer warns, persists the Claude provider instead, and returns 'claude'. Note CLAUDE_MEM_PROVIDER was already written as the selected provider just before the prompt, so this branch rewrites it back to claude — deliberate fallback, not data loss.
Source
Thrown at src/npx-cli/commands/install.ts:1268
const keyEnvName = selectedProvider === 'gemini'
? 'CLAUDE_MEM_GEMINI_API_KEY'
: 'CLAUDE_MEM_OPENROUTER_API_KEY';
const existingKey = getSetting(keyEnvName as keyof SettingsDefaults) as string | undefined;
if (existingKey && existingKey.trim().length > 0) {
const wrote = mergeSettings({ CLAUDE_MEM_PROVIDER: selectedProvider });
if (wrote) log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);
return selectedProvider;
}
const apiKeyResult = await p.password({
message: `Paste your ${providerLabel} API key:`,
mask: '*',
validate: (v?: string) => (!v || v.trim().length === 0) ? 'API key required' : undefined,
});
if (p.isCancel(apiKeyResult)) {
log.warn(`API key prompt cancelled — falling back to Claude provider.`);
persistClaudeProvider();
return 'claude';
}
const apiKey = String(apiKeyResult).trim();
const wrote = mergeSettings({
CLAUDE_MEM_PROVIDER: selectedProvider,
[keyEnvName]: apiKey,
});
if (wrote) {
log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);
}
return selectedProvider;
}
async function promptClaudeModel(options: InstallOptions): Promise<void> {
const allowed = new Set([
'claude-haiku-4-5-20251001',View on GitHub (pinned to e2d1df569a)
Solutions
- Nothing to fix if Claude fallback was intended — generation uses the Claude provider.
- To retry the third-party provider, rerun `npx claude-mem install` and paste the key when prompted.
- To set it non-interactively: merge CLAUDE_MEM_<PROVIDER>_API_KEY + CLAUDE_MEM_PROVIDER into settings.json or env.
Defensive patterns
Strategy: validation
Validate before calling
// Pre-set the third-party key so the prompt (and its cancel path) never happens:
// settings.json: { "env": { "CLAUDE_MEM_PROVIDER": "openrouter", "CLAUDE_MEM_OPENROUTER_API_KEY": "sk-or-..." } } Type guard
const isCancelled = (r: unknown): r is symbol => p.isCancel(r); // cancel => provider falls back to 'claude'; verify which provider actually won:
Prevention
- After any cancelled key prompt, verify CLAUDE_MEM_PROVIDER in settings.json reflects the fallback you expect.
- Provide keys upfront in automation to avoid the fallback path entirely.
- The fallback is intentional: Claude credentials keep generation working while you obtain the other key.
When it happens
Trigger: User cancels the p.password prompt for a third-party provider key after selecting that provider. persistClaudeProvider() then restores claude as the active provider so memory generation still has credentials.
Common situations: User has no third-party key yet; key lives in a vault not accessible; user changes mind mid-flow and wants the default Claude path.
Related errors
- API key prompt cancelled — leaving existing configuration un
- Gateway setup cancelled — leaving existing configuration unt
- Provider=${options.provider} requested non-interactively. AP
- bun install failed in ${targetDir} ${describeExecError(err)}
- auth_invalid
AI-assisted analysis of thedotmack/claude-mem@e2d1df569a (2026-08-20).
Data as JSON: /api/errors/695e246792e32c6e.
Report an issue: GitHub.