JuliusBrussee/caveman · error

no provider credential detected; pass --provider

Error message

no provider credential detected; pass --provider

What it means

With no --provider flag, the initializer infers the provider from credentials in the environment (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY/GOOGLE_API_KEY). Zero matches is only auto-resolvable in an interactive TTY (it would prompt); in non-interactive contexts — CI, piped stdin/stdout, scripts — there is nothing to prompt and no credential to infer, so it throws and tells you to pass --provider.

Source

Thrown at packages/create-caveman-agent/src/index.ts:139

    "TEMP", "TMP", "TMPDIR", "LANG", "LC_ALL", "LC_CTYPE", "TZ", "CI", "NO_COLOR", "FORCE_COLOR",
    "HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "no_proxy",
    "NPM_CONFIG_CACHE", "NPM_CONFIG_REGISTRY", "NPM_CONFIG_USERCONFIG",
    "npm_config_cache", "npm_config_registry", "npm_config_userconfig",
  ]) {
    if (process.env[key] !== undefined) env[key] = process.env[key];
  }
  return env;
}

async function chooseProvider(flag: string | undefined): Promise<Provider> {
  if (flag !== undefined) return parseProvider(flag);
  const detected: Provider[] = [];
  if (process.env.ANTHROPIC_API_KEY) detected.push("anthropic");
  if (process.env.OPENAI_API_KEY) detected.push("openai");
  if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) detected.push("google");
  if (detected.length === 1) return detected[0]!;
  if (!process.stdin.isTTY || !process.stdout.isTTY) {
    throw new Error(
      detected.length === 0
        ? "no provider credential detected; pass --provider"
        : "multiple provider credentials detected; pass --provider",
    );
  }
  const rl = createInterface({ input: process.stdin, output: process.stdout });
  try {
    const answer = await rl.question("Provider (anthropic/openai/google): ");
    return parseProvider(answer);
  } finally {
    rl.close();
  }
}

function projectFiles(name: string, provider: Provider): Record<string, string> {
  return {
    "package.json": `${JSON.stringify({
      name,

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. Pass the flag explicitly: `--provider anthropic` (or openai/google).
  2. Or export the matching credential before running, e.g. `export ANTHROPIC_API_KEY=...`, so detection succeeds.
  3. In CI, add the provider choice as a build parameter instead of relying on ambient credentials.

Example fix

# before (CI, no env keys)
npm create @caveman-ai/agent@latest myapp
# after
npm create @caveman-ai/agent@latest myapp --provider anthropic
Defensive patterns

Strategy: validation

Validate before calling

const CREDS = ["ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GEMINI_API_KEY", "GOOGLE_API_KEY"] as const;
function providerUnambiguous(): boolean {
  return CREDS.filter(k => Boolean(process.env[k])).length !== 0;
}

Prevention

When it happens

Trigger: Running the initializer in CI or with piped stdin/stdout where no ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, or GOOGLE_API_KEY is set in the environment.

Common situations: CI pipelines without provider secrets, local shells where the key lives in a different terminal session or direnv that was not loaded, or running the tool under another process (Docker, VS Code tasks) that strips the env.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/0858a33331b6ca41. Report an issue: GitHub.