Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Fix issue with skipping AI request when ANTHROPIC_API_KEY is not defined

Kiran K330dd1bcb3dd
diff --git a/apps/web/app/api/ai/generate-support-title/route.ts b/apps/web/app/api/ai/generate-support-title/route.ts
index e270bdb8da..633da11204 100644
--- a/apps/web/app/api/ai/generate-support-title/route.ts
+++ b/apps/web/app/api/ai/generate-support-title/route.ts
@@ -8,6 +8,11 @@ import { NextRequest } from "next/server";
export const runtime = "edge";
export async function POST(req: NextRequest) {
+ if (!anthropic) {
+ console.error("Anthropic is not configured. Skipping the request.");
+ return new Response(null, { status: 200 });
+ }
+
try {
const session = await getToken({
req,
@@ -35,7 +40,7 @@ export async function POST(req: NextRequest) {
const { prompt } = await req.json();
// Ask Claude for a streaming chat completion given the prompt
- const response = await anthropic.messages.create({
+ const response = await anthropic?.messages.create({
messages: [
{
role: "user",