-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
I am encountering an APIRemovedInV1
error when using the openai.ChatCompletion.create()
method in both local and Docker environments, despite using the latest versions of the OpenAI Python library (v1.45.0 and v1.46.0).
The error persists even after following the official migration guide and ensuring that the correct API is being used. I’ve tested this in multiple clean environments, including an isolated Docker container, but the issue still occurs.
The error message is:
APIRemovedInV1: You tried to access openai.ChatCompletion, but this is no longer supported in openai>=1.0.0
Expected Behavior:
I expect openai.ChatCompletion.create()
to work correctly without triggering the APIRemovedInV1
error, as per the latest API documentation.
Environment:
Python version: 3.10
OpenAI Python library version: 1.45.0 and 1.46.0 (tried both)
OS: Ubuntu (both local and Docker environments)
Additional Context:
I've purged all old versions of the OpenAI library and even rebuilt environments without caching (including Docker).
The issue persists even in fresh environments with no previous configurations.
I followed the official migration guide, and the method openai.ChatCompletion.create()
is being used as described in the documentation.
To Reproduce
Install openai via pip (pip install openai==1.45.0 or pip install openai==1.46.0).
Attempt to use openai.ChatCompletion.create() with the code snippet below:
Code snippets
import openai
openai.api_key = 'my api key from .env file'
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello, ChatGPT!"}
]
)
print(response['choices'][0]['message']['content'])
OS
Windows with WSL / Ubuntu
Python version
Python 3.12.12
Library version
openai 1.45.0 & openai 1.46.0