JuliusBrussee/caveman · error · Error

unsupported provider

Error message

unsupported provider ${JSON.stringify(value)}

What it means

Thrown by parseProvider in the create-caveman-agent scaffolder: the provider string, after trim and lowercasing, is not one of 'anthropic', 'openai', or 'google'. The raw value is echoed via JSON.stringify so whitespace or case issues are visible.

Solutions

  1. Use exactly one of: anthropic, openai, google (case-insensitive)
  2. For Gemini/Google models pass `--provider google`, not `gemini`
  3. Check for typos or stray whitespace/characters in the flag value

Example fix

// before
npm create @caveman-ai/agent@latest my-app -- --provider gemini
// after
npm create @caveman-ai/agent@latest my-app -- --provider google
Defensive patterns

Strategy: validation

Validate before calling

const PROVIDERS = new Set(["anthropic", "openai", "google"]);
const i = argv.indexOf("--provider");
if (i !== -1 && !PROVIDERS.has((argv[i + 1] ?? "").trim().toLowerCase())) {
  throw new Error(`provider must be one of anthropic|openai|google`);
}

Type guard

function isProvider(v: string): v is "anthropic" | "openai" | "google" {
  return ["anthropic", "openai", "google"].includes(v.trim().toLowerCase());
}

Try / catch

try {
  const opts = parseArgs(argv);
} catch (error) {
  if (error instanceof Error && error.message.startsWith("unsupported provider")) {
    console.error(`${error.message} — use anthropic, openai, or google`);
    process.exitCode = 1;
  } else throw error;
}

Prevention

When it happens

Trigger: Passing an unsupported or misspelled provider: `--provider Anthropic-AI`, `--provider claude`, `--provider gpt`, `--provider gemini` (note: gemini is NOT accepted — use `google`).

Common situations: Assuming model/brand names (claude, gemini, gpt) map to providers; typo `anthrpoaic`; using camelCase with extra characters the trim/lowercase doesn't fix (e.g. internal spaces become part of the value).

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/831db31402b0dcab. Report an issue: GitHub.

Appendix: source

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

npm run check
\`\`\`

Local results are inferred. Verified savings remain $0 until active real
traffic passes existing Caveman rollout and ledger gates.
`,
  };
}

function credentialName(provider: Provider): string {
  if (provider === "anthropic") return "ANTHROPIC_API_KEY";
  if (provider === "openai") return "OPENAI_API_KEY";
  return "GEMINI_API_KEY (or GOOGLE_API_KEY)";
}

function parseProvider(value: string): Provider {
  const normalized = value.trim().toLowerCase();
  if (normalized === "anthropic" || normalized === "openai" || normalized === "google") return normalized;
  throw new Error(`unsupported provider ${JSON.stringify(value)}`);
}

function safeName(value: string): string {
  const normalized = value.toLowerCase().replace(/[^a-z0-9_-]+/g, "-").replace(/^-+|-+$/g, "");
  if (!normalized) throw new Error("project name must contain a letter or number");
  return normalized.slice(0, 96);
}

async function assertAbsent(path: string): Promise<void> {
  try {
    await stat(path);
    throw new Error(`target already exists: ${path}`);
  } catch (error) {
    if ((error as NodeJS.ErrnoException).code !== "ENOENT") throw error;
  }
}

main().catch((error) => {

View on GitHub (pinned to 3ee70a1026)