I am trying to do a simple request to ChatGPT but get a 200 response with no content
{
"answer": {}
}
Why can i not read the completion (also, how can i stream it?)
import {
ChatCompletionRequestMessageRoleEnum,
Configuration,
OpenAIApi,
} from "openai-edge";
import config from "../../config";
import { NextApiRequest, NextApiResponse } from "next";
const openAIConfig = new Configuration({ apiKey: config.openAIKey });
const openAI = new OpenAIApi(openAIConfig);
export default async function handler(
req: NextApiRequest,
res: NextApiResponse<any>
) {
let messages = [
{
role: ChatCompletionRequestMessageRoleEnum.System,
content: "Hello, I'm a chatbot",
},
{
role: ChatCompletionRequestMessageRoleEnum.User,
content: "Hello, is Pluto really a planet?",
},
];
const completion = await openAI.createChatCompletion({
model: "gpt-3.5-turbo",
stream: false,
messages,
});
res.status(200).send(completion);
}