ChatGPT API
npm install @llm-utils/chatgpt-apijs
import { ChatGPTAPI } from '@llm-utils/chatgpt-api';
import nodeFetch from "node-fetch";
const main = async () => {
const api = new ChatGPTAPI({
apiKey: process.env.OPENAI_API_KEY,
fetch: nodeFetch
});
const resp = await api.createChatCompletions([
{
role: "system",
content: "You are a helpful assistant.",
},
{
role: "user",
content: "hi, what date in today?",
},
]);
console.log(resp);
}
main();
`
browser (esm)
`html
``