thedotmack/claude-mem · warning

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-setup flow, if the user cancels (Ctrl-C / Esc) the masked API key prompt, the installer does not abort. Instead it warns, persists the default 'claude' provider via persistClaudeProvider(), and returns 'claude' as the selected provider.

Solutions

  1. Rerun `npx claude-mem install` (or the provider setup) and paste the API key when prompted.
  2. Accept the Claude provider fallback if you want to use Anthropic via Claude subscription instead of a custom key.
  3. Manually update the provider settings (e.g. via claude-mem settings) later once the key is available.
Defensive patterns

Strategy: fallback

Validate before calling

if (!process.stdin.isTTY) {
  console.warn('API key prompt requires a TTY; provider will fall back to claude.');
}

Prevention

When it happens

Trigger: User selects a BYO-key provider (OpenRouter, etc.), is shown the `message: 'Paste your <provider> API key:'` prompt, and cancels it via p.isCancel — non-TTY or interrupt.

Common situations: User doesn't have the key handy and presses Esc/Ctrl-C; aborted prompt in a partially automated terminal; accidental interrupt.

Related errors


AI-assisted analysis of thedotmack/claude-mem@d8bc9755e7 (2026-09-17). Data as JSON: /api/errors/695e246792e32c6e. Report an issue: GitHub.

Appendix: source

Thrown at src/npx-cli/commands/install.ts:1223

    && isCmemGatewayUrl(existingOpenRouterBaseUrl);
  if (existingKey && existingKey.trim().length > 0 && !existingKeyIsCmem) {
    const wrote = mergeSettings({ CLAUDE_MEM_PROVIDER: selectedProvider });
    if (wrote) log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);
    return selectedProvider;
  }

  if (!isInteractive) {
    throw new Error(`Non-interactive ${providerLabel} configuration is missing a personal API key.`);
  }

  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 updates = selectedProvider === 'openrouter'
    ? buildPersonalOpenRouterSettings(
      apiKey,
      readPersistedInstallerSettings(),
      SettingsDefaultsManager.getAllDefaults().CLAUDE_MEM_OPENROUTER_MODEL,
    )
    : {
      CLAUDE_MEM_PROVIDER: selectedProvider,
      [keyEnvName]: apiKey,
    };
  const wrote = mergeSettings(updates);
  if (wrote) {
    log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);

View on GitHub (pinned to d8bc9755e7)