Then create your .env
to set OPENAI_API_KEY
and add to your .gitignore
1
| npm install @ai-sdk/openai
|
1
2
3
4
5
6
7
8
9
10
11
12
13
| // openai.ts
import { streamResponse } from "./streamResponse";
import { openai } from "@ai-sdk/openai";
import dotenv from "dotenv";
dotenv.config();
const model = openai("gpt-4o");
streamResponse(model).catch((error) =>
console.error("An error occurred:", error)
);
|
(Install npm i -g ts-node
if you haven't already.)
Assistant: Here are five fun penguin names you might like:
1. Waddles
2. Flipper
3. Snowball
4. Puddles
5. Chilly