Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 12 additions & 22 deletions src/app/api/health/route.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,19 @@
// GET /api/health — liveness by default; add ?strict=1 for readiness.
//
// A dead LLM key must never fail the check a kill-and-restart decision reads:
// restarting the process can't fix someone else's outage. So the plain check
// always returns 200 once the process is up, carrying `llm` as information
// only. `?strict=1` is the opt-in for a caller that actually wants to know
// whether analysis currently works — it 503s only when the chain has been
// down for `downAfter` consecutive requests.
// GET /api/health — liveness. A dead LLM key must never fail the check a
// kill-and-restart decision reads: restarting the process can't fix someone
// else's outage. Always 200 once the process is up; `llm` is informational.

import { NextRequest, NextResponse } from "next/server";
import { NextResponse } from "next/server";
import { getLLMHealth } from "@/lib/health";

export async function GET(req: NextRequest) {
export async function GET() {
const llm = getLLMHealth();
const strict = req.nextUrl.searchParams.get("strict") === "1";
const status = strict && llm.status === "down" ? 503 : 200;

return NextResponse.json(
{
success: true,
data: {
status: status === 200 ? "healthy" : "unhealthy",
llm,
timestamp: new Date().toISOString(),
},
return NextResponse.json({
success: true,
data: {
status: "healthy",
llm,
timestamp: new Date().toISOString(),
},
{ status },
);
});
}