'I am getting this error "AttributeError: 'module' object has no attribute 'Completion'" when I try to use openai

this is my code and I get this error when I try to run it

response = openai.Completion.create( AttributeError: 'module' object has no attribute 'Completion'

import os
import openai

openai.api_key = os.getenv("OPENAI_API_KEY")

response = openai.Completion.create(
  engine="text-davinci-002",
  prompt="Convert this text to a programmatic command:\n\nExample: Ask Constance if we need some bread\nOutput: send-msg `find constance` Do we need some bread?\n\nContact the ski store and figure out if I can get my skis fixed before I leave on Thursday\n\nsend-msg `find ski store` Can I get my skis fixed before I leave on Thursday?",
  temperature=0,
  max_tokens=100,
  top_p=1,
  frequency_penalty=0.2,
  presence_penalty=0
)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source