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 f7bdee9583
commit 4acf293690

View File

@ -282,26 +282,8 @@ export async function chat(
/** Check if configured LLM provider is available */
export async function checkHealth(): Promise<{ ok: boolean; model: string; provider: string; error?: string }> {
if (BLOG_LLM_PROVIDER === "anthropic" && ANTHROPIC_API_KEY) {
try {
// Quick validation — just check API key works
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 };
}
// Key presence check only — live API call causes 429 when pipeline is running
return { ok: true, model: ANTHROPIC_MODEL, provider: "anthropic" };
}
try {