thedotmack/claude-mem · error

Non-interactive configuration is missing a personal API key.

Error message

Non-interactive ${providerLabel} configuration is missing a personal API key.

What it means

Non-'claude' providers (OpenRouter/OpenAI-compatible) need a personal API key. In non-interactive mode there is no password prompt to collect one, so install throws this error when no key is available from settings/env for the selected provider. Interactive sessions instead prompt the user for the key.

Solutions

  1. Provide the key non-interactively: set the provider's API key in ~/.claude-mem/settings.json or the corresponding env var before running install.
  2. Run install in an interactive terminal so the password prompt can collect the key.
  3. Verify the key field name matches what the selected provider expects (e.g. CLAUDE_MEM_OPENROUTER_API_KEY).

Example fix

# before
cmem install --provider openrouter --yes   # no key anywhere
# after
printf '{"CLAUDE_MEM_OPENROUTER_API_KEY":"sk-or-v1-..."}' > ~/.claude-mem/settings.json
cmem install --provider openrouter --yes
Defensive patterns

Strategy: validation

Validate before calling

const key = settings.CLAUDE_MEM_OPENROUTER_API_KEY ?? process.env.CLAUDE_MEM_OPENROUTER_API_KEY;
if (!process.stdin.isTTY && provider !== 'claude' && !key) throw new Error(`non-interactive ${provider} install needs an API key in settings/env`);

Type guard

const hasKey = (s: SettingsLike): s is SettingsLike & { [k: string]: string } => typeof s.CLAUDE_MEM_OPENROUTER_API_KEY === 'string' && s.CLAUDE_MEM_OPENROUTER_API_KEY.length > 0;

Try / catch

try { await install(options); } catch (e) { if (e.message.includes('missing a personal API key')) { writeKeyToSettings(await promptForKeyElsewhere()); await install(options); } else throw e; }

Prevention

When it happens

Trigger: Running non-interactive install with --provider set to a key-based provider while the provider's API key is absent from settings (~/.claude-mem/settings.json) and environment, and isInteractive is false.

Common situations: CI/automation installs that set --provider openrouter but forgot the key env/settings; key stored under the wrong settings field name; fresh machine without migrated settings.

Understand the failure class

Background: "API key is required" / "API key not found" / "No API key was set": the missing-api-key error family across 16 libraries — this error's family across 16 libraries.

Related errors


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

Appendix: source

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

  const providerLabel = selectedProvider === 'gemini' ? 'Gemini' : 'OpenRouter';
  const keyEnvName = selectedProvider === 'gemini'
    ? 'CLAUDE_MEM_GEMINI_API_KEY'
    : 'CLAUDE_MEM_OPENROUTER_API_KEY';

  const existingKey = getSetting(keyEnvName as keyof SettingsDefaults) as string | undefined;
  const existingOpenRouterBaseUrl = selectedProvider === 'openrouter'
    ? String(getSetting('CLAUDE_MEM_OPENROUTER_BASE_URL') ?? '')
    : '';
  const existingKeyIsCmem = selectedProvider === 'openrouter'
    && 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,

View on GitHub (pinned to d8bc9755e7)