-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
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
Release 1.99.4 fixed a regression where ChatCompletionToolParam had changed from a TypedDict to a Union, causing any existing ChatCompletionToolParam(...)
constructors to break.
The same error is still occurring when trying to instantiate ChatCompletionMessageToolCallParam
.
Python 3.12.10 (main, May 30 2025, 05:53:56) [Clang 20.1.4 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import openai
>>> openai.__version__
'1.99.4'
>>> from openai.types.chat import ChatCompletionMessageToolCallParam
>>> ChatCompletionMessageToolCallParam()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/tylerpayne/.local/share/uv/python/cpython-3.12.10-macos-aarch64-none/lib/python3.12/typing.py", line 1184, in __call__
result = self.__origin__(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/tylerpayne/.local/share/uv/python/cpython-3.12.10-macos-aarch64-none/lib/python3.12/typing.py", line 501, in __call__
raise TypeError(f"Cannot instantiate {self!r}")
TypeError: Cannot instantiate typing.Union
To Reproduce
uvx --python 3.12 --with "openai==1.99.4" python
from openai.types.chat import ChatCompletionMessageToolCallParam
ChatCompletionMessageToolCallParam()
Code snippets
OS
macOS
Python version
Python v3.12.10
Library version
openai v1.99.4
afourney, mahmoudafif, wriga049, rafaelpierre, ryx2 and 3 more