Skip to content

Commit a1d79d5

Browse files
expose api key and base url
1 parent ca53765 commit a1d79d5

File tree

1 file changed

+7
-1
lines changed
  • samples/nextjs-openai/ui/src/app/api/chat

1 file changed

+7
-1
lines changed

samples/nextjs-openai/ui/src/app/api/chat/route.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
1-
import { openai } from "@ai-sdk/openai";
1+
import { createOpenAI } from "@ai-sdk/openai";
22
import { streamText } from "ai";
33

44
const system = "You are a helpful and knowledgeable expert about cloud computing. You are funny, and love to help others, and speak in short messages.";
55

6+
const openai = createOpenAI({
7+
baseURL: "https://api.openai.com/v1",
8+
apiKey: process.env.OPENAI_API_KEY,
9+
})
10+
11+
612
export async function POST(req: Request) {
713
const { messages } = await req.json();
814
const result = streamText({

0 commit comments

Comments
 (0)