{"record":{"id":"2f5123f79880f3c2","repo":"n8n-io/n8n","slug":"set-n8n-ai-anthropic-key-or-anthropic-api-key-th","errorCode":null,"errorMessage":"Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY — the judge LLM needs it.","messagePattern":"Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY — the judge LLM needs it\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/cli/pairwise.ts","lineNumber":640,"sourceCode":"\t\t\t`Report regeneration failed: ${error instanceof Error ? error.message : String(error)}`,\n\t\t);\n\t}\n}\n\n// ---------------------------------------------------------------------------\n// Main\n// ---------------------------------------------------------------------------\n\nasync function main(): Promise<void> {\n\tconst args = parseArgs(process.argv.slice(2));\n\tconst logger = createLogger(args.verbose);\n\tlogger.info(\n\t\t`pairwise eval: dataset=${args.dataset} judges=${args.judges} iterations=${args.iterations}`,\n\t);\n\n\tconst apiKey = process.env.N8N_AI_ANTHROPIC_KEY ?? process.env.ANTHROPIC_API_KEY;\n\tif (!apiKey) {\n\t\tthrow new Error('Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY — the judge LLM needs it.');\n\t}\n\n\tconst client = new N8nClient(args.baseUrl);\n\tawait client.login();\n\tconst preRunWorkflowIds = new Set(await client.listWorkflowIds());\n\tconst claimedWorkflowIds = new Set<string>();\n\tlogger.info(`Runner: orchestrator (${args.baseUrl})`);\n\n\tconst judgeLlm = new ChatAnthropic({\n\t\tmodel: args.judgeModel,\n\t\tapiKey,\n\t\ttemperature: 0,\n\t\tmaxTokens: 8192,\n\t});\n\n\tconst examples = await loadExamples(args, logger);\n\tlet filtered = examples;\n\tif (args.exampleIds) {","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/cli/pairwise.ts#L622-L658","documentation":"The pairwise judge LLM is a ChatAnthropic model that requires an API key. The CLI checks N8N_AI_ANTHROPIC_KEY first, then ANTHROPIC_API_KEY, and throws if neither is set before constructing the client. No key means the judge cannot score responses.","triggerScenarios":"Running `pnpm pairwise` in a shell where neither env var is exported; CI secrets not injected; .env file not loaded.","commonSituations":"Fresh terminal without sourcing the project env; CI matrix job missing the secret; key rotated and old value removed but new not yet added.","solutions":["Export N8N_AI_ANTHROPIC_KEY (preferred) or ANTHROPIC_API_KEY in the shell running the CLI.","In CI, add the secret to the job's environment block.","If using a .env file, ensure the loader (e.g. dotenv) runs before the CLI parses env."],"exampleFix":"// before: pnpm pairwise --dataset foo\n// after:  N8N_AI_ANTHROPIC_KEY=sk-... pnpm pairwise --dataset foo","handlingStrategy":"validation","validationCode":"const apiKey = process.env.N8N_AI_ANTHROPIC_KEY ?? process.env.ANTHROPIC_API_KEY;\nif (!apiKey) throw new Error('Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add a startup env-check that fails fast with actionable text.","Wire the secret into CI via the secrets manager, not the shell history.","Use a .env loader for local dev."],"tags":["env","config","llm","auth"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}