Run this in your Python environment:
import pydantic_core, pydantic
print(pydantic_core.__version__, pydantic.__version__)
Output result meeting the latest supported:
2.20.1 2.8.2
If you have lesser or greater versions in your Python 3.9-3.11 environment for OpenAI API requests, try this forced upgrade line from the user account (with access to upgrade those installations) or on the venv:
pip install --upgrade --upgrade-strategy eager regex "charset-normalizer<4" "idna" "urllib3<3" "certifi" "requests" "anyio<5" "distro<2" "sniffio" "h11<0.15" "httpcore==1.*" "httpx<1" "annotated-types" "typing-extensions<5" "pydantic-core==2.20.1" "pydantic<3" "jiter<1" "tqdm" "colorama" "openai" "tiktoken"
If you have broader application use in the environment, you should also verify those requirements match what other software you are running, otherwise you may need a separate venv for your API calls.
Pydantic here is the most suspect in sending unanticipated output to the API by different versions, whereas the most reliable code across various runtime platforms will be using simply a https-supporting library and your own support written for sending JSON to the API endpoint URL.
Explanation: openai
has broad version numbers as requirements that may be less strict than the upgrades required for compatibility with the platform the latest SDK version is auto-built for. Later explicit upgrades to libraries may not consider all requirements to maintain lower versions.