n8n-io/n8n · error · Error
Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY — the judge LL
Error message
Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY — the judge LLM needs it.
What it means
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.
Source
Thrown at packages/@n8n/instance-ai/evaluations/cli/pairwise.ts:640
`Report regeneration failed: ${error instanceof Error ? error.message : String(error)}`,
);
}
}
// ---------------------------------------------------------------------------
// Main
// ---------------------------------------------------------------------------
async function main(): Promise<void> {
const args = parseArgs(process.argv.slice(2));
const logger = createLogger(args.verbose);
logger.info(
`pairwise eval: dataset=${args.dataset} judges=${args.judges} iterations=${args.iterations}`,
);
const apiKey = process.env.N8N_AI_ANTHROPIC_KEY ?? process.env.ANTHROPIC_API_KEY;
if (!apiKey) {
throw new Error('Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY — the judge LLM needs it.');
}
const client = new N8nClient(args.baseUrl);
await client.login();
const preRunWorkflowIds = new Set(await client.listWorkflowIds());
const claimedWorkflowIds = new Set<string>();
logger.info(`Runner: orchestrator (${args.baseUrl})`);
const judgeLlm = new ChatAnthropic({
model: args.judgeModel,
apiKey,
temperature: 0,
maxTokens: 8192,
});
const examples = await loadExamples(args, logger);
let filtered = examples;
if (args.exampleIds) {View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before: pnpm pairwise --dataset foo // after: N8N_AI_ANTHROPIC_KEY=sk-... pnpm pairwise --dataset foo
Defensive patterns
Strategy: validation
Validate before calling
const apiKey = process.env.N8N_AI_ANTHROPIC_KEY ?? process.env.ANTHROPIC_API_KEY;
if (!apiKey) throw new Error('Set N8N_AI_ANTHROPIC_KEY or ANTHROPIC_API_KEY'); Prevention
- 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.
When it happens
Trigger: Running `pnpm pairwise` in a shell where neither env var is exported; CI secrets not injected; .env file not loaded.
Common situations: Fresh terminal without sourcing the project env; CI matrix job missing the secret; key rotated and old value removed but new not yet added.
Related errors
- Unknown agents module: "${moduleName}". ${validTokens ? `Val
- Failed to enable MCP access (server reported mcpAccessEnable
- seed.endpoint "${endpoint}" matches no configured LangSmith
- File not found
- Security settings are managed via environment variables and
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/2f5123f79880f3c2.
Report an issue: GitHub.