Files
podcastdistributiona/lib/ai/openai.ts
T

17 lines
512 B
TypeScript
Raw Normal View History

import OpenAI from "openai";
let client: OpenAI | null = null;
/** Lazily-constructed OpenAI client (used for GPT-4 scripts and DALL·E art). */
export function openai(): OpenAI {
if (!client) {
const apiKey = process.env.OPENAI_API_KEY;
if (!apiKey) throw new Error("OPENAI_API_KEY is not set");
client = new OpenAI({ apiKey });
}
return client;
}
export const SCRIPT_MODEL = process.env.OPENAI_SCRIPT_MODEL ?? "gpt-4o";
export const ART_MODEL = process.env.OPENAI_ART_MODEL ?? "dall-e-3";