openai.createCompletion

Returns a predicted completion for the given prompt.

Syntax

createCompletion(params)

Parameters

Return value

An object containing response from OpenAI API.

Example

await openai.createCompletion({
  model: "text-davinci-003",
  prompt: "In the future, AI will",
  max_tokens: 7,
  temperature: 0,
})
{
  id: cmpl-6msIA4IeyQ255mHcAsKXsa9dqllUJ,
  object: text_completion,
  created: 1677106462,
  model: text-davinci-003,
  choices: [{
             text:  be used to automate many tasks that,
             index: 0,
             logprobs: null,
             finish_reason: length
           }],
  usage: {
           prompt_tokens: 6,
           completion_tokens: 7,
           total_tokens: 13
         }
}

External resources