Skip to content

Commit

Permalink
get openai api key from process
Browse files Browse the repository at this point in the history
  • Loading branch information
nexxeln committed Jul 10, 2024
1 parent ae8b920 commit 2ac22d6
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
@@ -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<string> => {
const result = await generateText({
model: openai("gpt-4o"),
Expand Down

0 comments on commit 2ac22d6

Please sign in to comment.