The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Skip ai request if ANTHROPIC_API_KEY not defined
Kiran K9494c1ced552
diff --git a/apps/web/app/api/ai/completion/route.ts b/apps/web/app/api/ai/completion/route.tsindex 0cd491fb0c..658b29cc3c 100644--- a/apps/web/app/api/ai/completion/route.ts+++ b/apps/web/app/api/ai/completion/route.ts@@ -26,6 +26,11 @@ export async function POST(req: NextRequest) {const { workspaceId } = searchParams;const workspace = await getWorkspaceViaEdge(workspaceId);+ if (!anthropic) {+ console.error("Anthropic is not configured. Skipping the request.");+ return new Response(null, { status: 200 });+ }+if (!workspace) {return new Response("Workspace not found", { status: 404 });}diff --git a/apps/web/lib/anthropic.ts b/apps/web/lib/anthropic.tsindex 2929a63aef..555edf5f15 100644--- a/apps/web/lib/anthropic.ts+++ b/apps/web/lib/anthropic.ts@@ -1,5 +1,5 @@import Anthropic from "@anthropic-ai/sdk";-export const anthropic = new Anthropic({- apiKey: process.env.ANTHROPIC_API_KEY || "",-});+const apiKey = process.env.ANTHROPIC_API_KEY;++export const anthropic = apiKey ? new Anthropic({ apiKey }) : null;