Thanks for the clarification . When I try
var source = new SSE(
"https://api.openai.com/v1/engines/curie/completions",
{
headers: {
"Content-Type": "application/json",
Authorization:
"Bearer API_KEY",
},
method: "POST",
payload: JSON.stringify({
engine: "curie",
prompt: text,
temperature: 0.75,
top_p: 0.95,
max_tokens: 3,
stream: true,
stop: ["\n\n"],
}),
}
);
source.addEventListener("message", function (e: any) {
// Assuming we receive JSON-encoded data payloads:
var payload = JSON.parse(e.data);
console.log(payload);
});
source.stream();
I get errors. What does a working implementation look like?