Skip to content

Instantly share code, notes, and snippets.

@brianfoody
Created April 12, 2023 04:07
Show Gist options
  • Save brianfoody/fccf79b7b96381f1659a7202285b37d9 to your computer and use it in GitHub Desktop.
Save brianfoody/fccf79b7b96381f1659a7202285b37d9 to your computer and use it in GitHub Desktop.
gpt4
const payload = {
model: "gpt-4",
messages: [
{
content: `Tell me the days of the week.`,
role: "user",
} as ChatGptMessage,
],
temperature: 0.8,
top_p: 1,
frequency_penalty: 0.5,
presence_penalty: 0.0,
max_tokens: 1000,
n: 1,
};
// const stream = await ChatGPTStream(payload);
// return new Response(stream);
const completion = await fetch("https://api.openai.com/v1/chat/completions", {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer sk-xxxx`,
},
method: "POST",
body: JSON.stringify(payload),
}).then((x) => x.json());
console.log(JSON.stringify(completion));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment