{"record":{"id":"39b3e2c588afd89b","repo":"thedotmack/claude-mem","slug":"non-interactive-providerlabel-configuration-is","errorCode":null,"errorMessage":"Non-interactive ${providerLabel} configuration is missing a personal API key.","messagePattern":"Non-interactive (.+?) configuration is missing a personal API key\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/npx-cli/commands/install.ts","lineNumber":1190,"sourceCode":"  const providerLabel = selectedProvider === 'gemini' ? 'Gemini' : 'OpenRouter';\n  const keyEnvName = selectedProvider === 'gemini'\n    ? 'CLAUDE_MEM_GEMINI_API_KEY'\n    : 'CLAUDE_MEM_OPENROUTER_API_KEY';\n\n  const existingKey = getSetting(keyEnvName as keyof SettingsDefaults) as string | undefined;\n  const existingOpenRouterBaseUrl = selectedProvider === 'openrouter'\n    ? String(getSetting('CLAUDE_MEM_OPENROUTER_BASE_URL') ?? '')\n    : '';\n  const existingKeyIsCmem = selectedProvider === 'openrouter'\n    && isCmemGatewayUrl(existingOpenRouterBaseUrl);\n  if (existingKey && existingKey.trim().length > 0 && !existingKeyIsCmem) {\n    const wrote = mergeSettings({ CLAUDE_MEM_PROVIDER: selectedProvider });\n    if (wrote) log.info(`Saved provider=${selectedProvider} to ~/.claude-mem/settings.json`);\n    return selectedProvider;\n  }\n\n  if (!isInteractive) {\n    throw new Error(`Non-interactive ${providerLabel} configuration is missing a personal API key.`);\n  }\n\n  const apiKeyResult = await p.password({\n    message: `Paste your ${providerLabel} API key:`,\n    mask: '*',\n    validate: (v?: string) => (!v || v.trim().length === 0) ? 'API key required' : undefined,\n  });\n\n  if (p.isCancel(apiKeyResult)) {\n    log.warn(`API key prompt cancelled — falling back to Claude provider.`);\n    persistClaudeProvider();\n    return 'claude';\n  }\n\n  const apiKey = String(apiKeyResult).trim();\n  const updates = selectedProvider === 'openrouter'\n    ? buildPersonalOpenRouterSettings(\n      apiKey,","sourceCodeStart":1172,"sourceCodeEnd":1208,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/npx-cli/commands/install.ts#L1172-L1208","documentation":"Providers other than 'cmem' and 'claude' (i.e. bring-your-own-key providers) need a personal API key. In non-interactive mode there is no password prompt to collect one, so if the key has not already been provided/staged the install throws this error naming the provider.","triggerScenarios":"Running the installer non-interactively with a BYOK provider selected (options.provider set to e.g. 'openrouter'-style provider) and no API key supplied through settings/env or prior configuration, while isInteractive is false.","commonSituations":"CI/automation installing claude-mem with a custom provider but forgetting to stage the API key; key removed from ~/.claude-mem/settings.json; rerunning install after clearing credentials.","solutions":["Provide the API key non-interactively (e.g. export the provider's key env var or put it in ~/.claude-mem/settings.json) and rerun install","Run the installer in an interactive terminal so it can prompt: 'Paste your <provider> API key:'","Switch to a provider that does not need a personal key (e.g. --provider claude) for non-interactive installs"],"exampleFix":"// before\nnpx claude-mem install --provider grok-bot < /dev/null\n// after\nexport GROKBOT_API_KEY=xai-...\nnpx claude-mem install --provider grok-bot < /dev/null","handlingStrategy":"validation","validationCode":"const needsKey = provider !== 'claude' && provider !== 'cmem';\nif (needsKey && !process.stdin.isTTY && !hasStoredApiKey(provider)) {\n  throw new Error(`Provide an API key for ${provider} before non-interactive install`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await runInstall({ provider });\n} catch (e) {\n  if (e.message.includes('is missing a personal API key')) {\n    console.error(`Set the ${provider} API key in settings/env, or run interactively.`);\n  } else throw e;\n}","preventionTips":["Stage the provider's API key in ~/.claude-mem/settings.json or the env before scripted installs","Run install interactively the first time to store the key, then automate safely","Verify key presence in settings before CI install steps"],"tags":["api-key","non-interactive","install","credentials"],"backgroundTag":"missing-api-key","analyzedSha":"8bc631a71a487424b866756e43a6efa4574cc66b","analyzedAt":"2026-09-09T10:47:06.009Z","contentChangedAt":"2026-09-09T10:47:06.009Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}