How to generate multiple completions in one go?

The openai Python library function openai.Completion() returns a list of “choices”:

  "choices": [
      "finish_reason": "stop",
      "index": 0,
      "logprobs": null,
      "text": "\n\nLorem Ipsum"
  "created": 1629960484,
  "id": "cmpl-3b3TAr9GJJx0Kq4y0HkriaU1nDBKY",
  "model": "if-davinci-v2",
  "object": "text_completion"

Is it possible to generate more than one “choices” in one run? (I’m pretty sure this is possible because otherwise it wouldn’t make sense that the functions returns a list which always only contains just entry. Moroever, I read that if the best_of parameter is set to a number larger than one, this is using something along these lines internally.

I tried adding parameters like choices=3 or num_choices=3 to the function but had no luck guessing the correct parameter name.

1 Like