I’m only familiar with “openai.chat.completions.create()” in the API? If you put a ‘breakpoint()’ before that create call, type in ‘p dir(openai)’ at the python debug prompt to see if there is a ‘completions’ method there.
Try using this code. Also note that text-davinci-002 was deprecated early this year and has been replaced by the gpt-3.5-turbo-instruct model.
from openai import OpenAI
import os
client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY","REPLACE WITH YOUR OPENAI KEY"))
completion = client.completions.create(
model="gpt-3.5-turbo-instruct",
prompt="This is a test.",
temperature=0,
max_tokens=500
)
print(completion.choices[0].text)