lib/anthropic.ts
Rama main · réplica de lectura del repositorio original.
import Anthropic from "@anthropic-ai/sdk";
let anthropicClient: Anthropic | null = null;
export function getAnthropicClient() {
if (anthropicClient) return anthropicClient;
const apiKey = process.env.ANTHROPIC_API_KEY;
if (!apiKey) {
throw new Error("AI generation is not configured.");
}
anthropicClient = new Anthropic({ apiKey });
return anthropicClient;
}