fix(llm): checkHealth uses key presence check, not live API call

Live Anthropic API call during health check causes 429 when the pipeline
is actively running, blocking all subsequent regenerate requests.
This commit is contained in:
Rene Fichtmueller 2026-04-06 04:07:21 +02:00
parent 7533202723
commit 6e383996e3

View File

@ -282,26 +282,8 @@ export async function chat(
/** Check if configured LLM provider is available */ /** Check if configured LLM provider is available */
export async function checkHealth(): Promise<{ ok: boolean; model: string; provider: string; error?: string }> { export async function checkHealth(): Promise<{ ok: boolean; model: string; provider: string; error?: string }> {
if (BLOG_LLM_PROVIDER === "anthropic" && ANTHROPIC_API_KEY) { if (BLOG_LLM_PROVIDER === "anthropic" && ANTHROPIC_API_KEY) {
try { // Key presence check only — live API call causes 429 when pipeline is running
// Quick validation — just check API key works return { ok: true, model: ANTHROPIC_MODEL, provider: "anthropic" };
const resp = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"Content-Type": "application/json",
"x-api-key": ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01",
},
body: JSON.stringify({
model: ANTHROPIC_MODEL,
max_tokens: 5,
messages: [{ role: "user", content: "hi" }],
}),
signal: AbortSignal.timeout(10000),
});
return { ok: resp.ok, model: ANTHROPIC_MODEL, provider: "anthropic" };
} catch (err) {
return { ok: false, model: ANTHROPIC_MODEL, provider: "anthropic", error: (err as Error).message };
}
} }
try { try {