Reputation: 11
I'm running my code in annaconda spyder(Windows) and getting "InvalidRequestError: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?" error. Have tried inserting env variable in spyder.
` from openai import OpenAI
def generate_synonyms(word):
client = OpenAI()
prompt = f"Can you provide synonyms for the word '{word}'?"
completion = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "I'm an assistant capable of providing information on various topics."},
{"role": "user", "content": prompt},
]
)
return completion.choices[0].message
word = "battery"
synonyms = generate_synonyms(word)
print("Synonyms for the word", word + ":", synonyms)`
This is my code.
Upvotes: 1
Views: 40