Issue with OpenAI Python Library (Version 0.27.2) - InvalidRequestError

Here is the code:

openai.api_key = API_KEY
model_id = ‘gpt-3.5-turbo’

def ChatGPT_conversation(conversation):
response = openai.ChatCompletion.create(
# api_usage = response[‘usage’]
# print(‘Total token consumed: {0}’.format(api_usage[‘total_tokens’]))
# stop means complete
# print(response[‘choices’][0].finish_reason)
# print(response[‘choices’][0].index)
conversation.append({‘role’: response.choices[0].message.role, ‘content’: response.choices[0].message.content})
return conversation

conversation =
conversation.append({‘role’: ‘system’, ‘content’: ‘How may I help you?’})
conversation = ChatGPT_conversation(conversation)
print(‘{0}: {1}\n’.format(conversation[-1][‘role’].strip(), conversation[-1][‘content’].strip()))

while True:
prompt = input(‘User:’)
conversation.append({‘role’: ‘user’, ‘content’: prompt})
conversation = ChatGPT_conversation(conversation)
print(‘{0}: {1}\n’.format(conversation[-1][‘role’].strip(), conversation[-1][‘content’].strip()))

InvalidRequestError: This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?

Subject: Issue with OpenAI Python Library (Version 0.27.2) - InvalidRequestError

Dear OpenAI Support Team,

I hope this message finds you well. I have been encountering an issue while trying to use the GPT-3.5 Turbo model with the OpenAI Python library (version 0.27.2) and would appreciate your assistance in resolving the problem.

Here are the relevant details:

  1. OpenAI Python library version: 0.27.2
  2. Example code used:

goCopy code

import openai

openai.api_key = "your_api_key_here"

messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Tell me a joke."},

response = openai.ChatCompletion.create(

  1. Error message encountered: “InvalidRequestError: Invalid URL (POST /v1/engines/gpt-3.5-turbo/chat/completions)”

I have tried uninstalling and reinstalling the OpenAI Python library, but the issue persists. Based on the information provided, I would appreciate any guidance or suggestions on how to resolve this problem.

Thank you for your time and support.

Best regards,

There is a good reply on the projects github issues page:

The library is slow as garbage. Write your own API call.

Same issue, trying to use text-ada-001.