Skip to content

Instantly share code, notes, and snippets.

@greenido
Created March 19, 2023 23:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenido/34ee9e3c694f245ae430dbc471c4ff92 to your computer and use it in GitHub Desktop.
Save greenido/34ee9e3c694f245ae430dbc471c4ff92 to your computer and use it in GitHub Desktop.
A simple call to openai API
const { Configuration, OpenAIApi } = require("openai");
async function main() {
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
const openai = new OpenAIApi(configuration);
const completion = await openai.createCompletion({
model: "text-davinci-003",
prompt: "how to bake a bread",
temperature: 0.6
});
console.log(completion.data.choices[0].text);
}
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment