{"record":{"id":"7ca788b733777c88","repo":"thedotmack/claude-mem","slug":"provider-options-provider-requested-non-interac","errorCode":null,"errorMessage":"Provider=${options.provider} requested non-interactively. API key prompt skipped — set CLAUDE_MEM_${options.provider.toUpperCase()}_API_KEY and CLAUDE_MEM_PROVIDER in settings.json or env manually if not already set.","messagePattern":"Provider=(.+?) requested non-interactively\\. API key prompt skipped — set CLAUDE_MEM_(.+?)_API_KEY and CLAUDE_MEM_PROVIDER in settings\\.json or env manually if not already set\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/npx-cli/commands/install.ts","lineNumber":1128,"sourceCode":"    }\n    saveClaudeMemEnv(env);\n    persistClaudeProvider('gateway');\n    if (tokenCancelled || tokenInput.length === 0) {\n      log.info('Gateway URL saved; existing gateway token preserved.');\n    } else {\n      log.info('Configured Claude Agent SDK gateway in ~/.claude-mem/.env.');\n    }\n  };\n\n  if (!isInteractive) {\n    if (options.provider) {\n      if (options.provider === 'claude') {\n        persistClaudeProvider();\n        return 'claude';\n      }\n      const wrote = mergeSettings({ CLAUDE_MEM_PROVIDER: options.provider });\n      if (wrote) log.info(`Saved provider=${options.provider} to ~/.claude-mem/settings.json`);\n      log.warn(`Provider=${options.provider} requested non-interactively. API key prompt skipped — set CLAUDE_MEM_${options.provider.toUpperCase()}_API_KEY and CLAUDE_MEM_PROVIDER in settings.json or env manually if not already set.`);\n      return options.provider;\n    }\n    return initialProvider;\n  }\n\n  const runClaudeAuthFlow = async (): Promise<void> => {\n    const resolvedAuthMethod = resolveClaudeAuthMethod();\n    const initialAccessMode: ClaudeAccessMode =\n      resolvedAuthMethod === 'subscription' ? 'subscription' : 'api-key';\n\n    const result = await p.select<ClaudeAccessMode>({\n      message: 'Do you use a subscription plan or an API key/gateway for the memory agent?',\n      options: [\n        { value: 'subscription', label: 'Subscription plan (recommended — uses your logged-in Claude SDK account)' },\n        { value: 'api-key', label: 'API key or gateway (Anthropic, LiteLLM, or compatible proxy)' },\n      ],\n      initialValue: initialAccessMode,\n    });","sourceCodeStart":1110,"sourceCodeEnd":1146,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/e2d1df569a8f04075d40e92461128ece7cf04c82/src/npx-cli/commands/install.ts#L1110-L1146","documentation":"When `npx claude-mem install` runs non-interactively (no TTY) with --provider other than 'claude', there is no way to prompt for that provider's API key. The installer persists CLAUDE_MEM_PROVIDER and warns that you must set CLAUDE_MEM_<PROVIDER>_API_KEY yourself (settings.json env block or real env), or generation calls with that provider will fail auth later.","triggerScenarios":"CI, Dockerfiles, or scripts running `claude-mem install --provider gemini|openrouter` with stdin/stdout detached. For provider 'claude' it persists the Claude provider and returns silently; every other provider hits this warning.","commonSituations":"Automated container builds; provisioning scripts that forget secrets must be injected at runtime, not install time.","solutions":["Set the key in the environment the worker/hooks run in: `CLAUDE_MEM_GEMINI_API_KEY=...` / `CLAUDE_MEM_OPENROUTER_API_KEY=...` (any CLAUDE_MEM_<PROVIDER>_API_KEY naming).","Or write it into ~/.claude-mem/settings.json under env alongside CLAUDE_MEM_PROVIDER.","If you actually wanted interactive key entry, run install in a real TTY without --provider.","Verify afterwards: `npx claude-mem doctor` or a test generation run to confirm the provider key resolves."],"exampleFix":"# before (Dockerfile, non-interactive):\nRUN npx claude-mem install --provider openrouter\n# after\nRUN npx claude-mem install --provider openrouter\nENV CLAUDE_MEM_OPENROUTER_API_KEY=sk-or-...","handlingStrategy":"validation","validationCode":"// Pre-flight everything non-interactive install needs, BEFORE running it:\nconst provider = 'openrouter'; // or gemini\nconst keyName = `CLAUDE_MEM_${provider.toUpperCase()}_API_KEY`;\nif (!process.env[keyName]) {\n  throw new Error(`${keyName} must be set for non-interactive --provider ${provider}`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always inject CLAUDE_MEM_<PROVIDER>_API_KEY via env/settings when scripting installs.","Smoke-test after automated install (one generation call) — a missing key only fails at first use.","Remember provider='claude' needs no key at install time; others do."],"tags":["install","non-interactive","env-var","api-key","provider"],"backgroundTag":"missing-env-var","analyzedSha":"e2d1df569a8f04075d40e92461128ece7cf04c82","analyzedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-08-21T08:17:14.275Z"}