diff --git a/index.ts b/index.ts index ab3d21a..70dd14b 100644 --- a/index.ts +++ b/index.ts @@ -1,9 +1,17 @@ import fs from "node:fs"; import { z } from "zod"; import { generateText, tool } from "ai"; -import { openai } from "@ai-sdk/openai"; +import { createOpenAI } from "@ai-sdk/openai"; import { $ } from "bun"; +if (!process.env.OPENAI_API_KEY) { + throw new Error("OPENAI_API_KEY is required"); +} + +const openai = createOpenAI({ + apiKey: process.env.OPENAI_API_KEY, +}); + const generateTestCases = async (prompt: string): Promise => { const result = await generateText({ model: openai("gpt-4o"),