import openai
openai.api_key = "my key"
# list models
models = openai.Model.list()
# print the first model's id
print(models.data[0].id)
# create a chat completion
chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello world"}])
# print the chat completion
print(chat_completion.choices[0].message.content)
whisper-1
Traceback (most recent call last):
File "c:\Users\admin\Desktop\test-code\test.py", line 25, in <module>
chat_completion = openai.ChatCompletion.create(model="gpt-3.5-turbo", messages=[{"role": "user", "content": "Hello world"}])
File "C:\Python310\lib\site-packages\openai\api_resources\chat_completion.py", line 25, in create
return super().create(*args, **kwargs)
File "C:\Python310\lib\site-packages\openai\api_resources\abstract\engine_api_resource.py", line 153, in create
response, _, api_key = requestor.request(
File "C:\Python310\lib\site-packages\openai\api_requestor.py", line 230, in request
resp, got_stream = self._interpret_response(result, stream)
File "C:\Python310\lib\site-packages\openai\api_requestor.py", line 624, in _interpret_response
self._interpret_response_line(
File "C:\Python310\lib\site-packages\openai\api_requestor.py", line 687, in _interpret_response_line
raise self.handle_error_response(
openai.error.InvalidRequestError: This is not a chat model and thus not supported in the v1/chat/completions endpoint. Did you mean to use v1/completions?
Describe the bug
Code example using readme:
The following is the error message
To Reproduce
I thought it was a problem with my SDK, so I tried playgroundand it was also an error.
Code snippets
No response
OS
win
Python version
3.10.4
Library version
0.27.7