Compelation.create error pls helpp

I am making an bot which uses chat gpt i am getting an error of compelation.create error where it says compelation is not defined here is proof

here is the code snippet- ### MAKE .env FILE AND SAVE YOUR API KEY ###
openai.api_key = os.environ[“OPENAI_API”]
response = completions.create(
engine=“gpt-3.5-turbo-instruct”,
prompt=f"Generate content on - "{theme}"",
temperature=0.7,
max_tokens=200,
top_p=1,
frequency_penalty=0,
presence_penalty=0

api endpoint is changed code you provided is depriciated in openai 1.23.6 here is the new code structure

from openai import OpenAI
client = OpenAI()

completion = client.chat.completions.create(
model=“No models available”,
messages=[
{“role”: “system”, “content”: “You are a helpful assistant.”},
{“role”: “user”, “content”: “Hello!”}
]
)

print(completion.choices[0].message)

for more detail refer to this :https://platform.openai.com/docs/api-reference/chat/create

1 Like

it just says client is not defined in line 21 pls help i am on lateest version of openai
i put the entire thing
image

you also need to make a openai object named client first, that is why youre getting the error add this line at the begining and pass your api key as argument
client=OpenAI(api_key=" ")