Created
March 19, 2023 23:35
-
-
Save greenido/34ee9e3c694f245ae430dbc471c4ff92 to your computer and use it in GitHub Desktop.
A simple call to openai API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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