{"record":{"id":"fc06ccf5d9a68a5d","repo":"JuliusBrussee/caveman","slug":"caveman-code-no-supported-provider-credential-fou","errorCode":null,"errorMessage":"caveman-code: no supported provider credential found; set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY","messagePattern":"caveman-code: no supported provider credential found; set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/agent/src/code.ts","lineNumber":562,"sourceCode":"}\n\nfunction resolveCodingModelID(explicit: string | undefined): string {\n  const requested = explicit ?? process.env.CAVE_MODEL;\n  if (requested !== undefined && requested !== \"\") {\n    const slash = requested.indexOf(\"/\");\n    if (slash <= 0 || slash === requested.length - 1) {\n      throw new Error(\"caveman-code: model must use provider/model format\");\n    }\n    return requested;\n  }\n  const configured: string[] = [];\n  if (process.env.ANTHROPIC_API_KEY) configured.push(\"anthropic/claude-sonnet-4-6\");\n  if (process.env.OPENAI_API_KEY) configured.push(\"openai/gpt-5.5\");\n  if (process.env.GEMINI_API_KEY || process.env.GOOGLE_API_KEY) {\n    configured.push(\"google/gemini-2.5-pro\");\n  }\n  if (configured.length !== 1) {\n    throw new Error(\n      configured.length === 0\n        ? \"caveman-code: no supported provider credential found; set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY\"\n        : \"caveman-code: multiple provider credentials found; set CAVE_MODEL to pick one\",\n    );\n  }\n  return configured[0]!;\n}\n\n// ---------------------------------------------------------------------------\n// Session\n// ---------------------------------------------------------------------------\n\nexport type SessionMode = \"optimized\" | \"observe-only\";\n\nexport interface CodingSessionOptions {\n  conversation?: ConversationState;\n  cave?: \"auto\" | \"off\";\n  gatewayURL?: string;","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/agent/src/code.ts#L544-L580","documentation":"When no explicit model is given, resolveCodingModelID builds candidates from provider credential env vars (ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY/GOOGLE_API_KEY). If none are set, there is no model to default to, so the library throws telling you to set one of the supported credentials.","triggerScenarios":"Calling caveman-code without a model argument/CAVE_MODEL while none of ANTHROPIC_API_KEY, OPENAI_API_KEY, GEMINI_API_KEY, or GOOGLE_API_KEY is present in the environment.","commonSituations":"CI environments without exported secrets; running in a fresh shell where keys were set in another profile; using a provider (e.g. Bedrock, Azure) whose credential vars this library does not recognize.","solutions":["Export ANTHROPIC_API_KEY (or OPENAI_API_KEY / GEMINI_API_KEY) in the environment","Set CAVE_MODEL plus the matching credential env var so the model resolves explicitly","Verify the key is exported in the same shell/process that runs caveman-code"],"exampleFix":"// before\n$ cave run   # no credentials in env\n// after\n$ export ANTHROPIC_API_KEY=sk-ant-...\n$ cave run","handlingStrategy":"fallback","validationCode":"const hasCred = [\"ANTHROPIC_API_KEY\", \"OPENAI_API_KEY\", \"GEMINI_API_KEY\", \"GOOGLE_API_KEY\"]\n  .some((k) => !!process.env[k]);\nif (!hasCred && !process.env.CAVE_MODEL) {\n  throw new Error(\"Set ANTHROPIC_API_KEY, OPENAI_API_KEY, or GEMINI_API_KEY before running\");\n}","typeGuard":"null","tryCatchPattern":"try {\n  await run(task);\n} catch (err) {\n  if ((err as Error).message.includes(\"no supported provider credential\")) {\n    console.error(\"Export a provider API key (ANTHROPIC_API_KEY / OPENAI_API_KEY / GEMINI_API_KEY) and retry\");\n  } else throw err;\n}","preventionTips":["Export one provider key in your shell profile and verify it in the same process","Check env vars exist in CI with a pre-flight step before running agents","Remember only Anthropic/OpenAI/Gemini credentials are auto-detected; others need explicit CAVE_MODEL"],"tags":["env","credentials","configuration"],"backgroundTag":"missing-api-key","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}