pydantic_chatcompletion is a simple but powerful wrapper for OpenAI's ChatCompletion API that enables “one line of code” extraction of structured data from unstructured text using OpenAI and Pydantic.<p>By providing a Pydantic model as an additional argument to an OpenAI ChatCompletion call, this package allows developers to easily obtain structured data that conforms to their Pydantic model definition.<p>It works by inserting a tuned prompt that includes the Pydantic model’s json_schema.<p>Post-completion it further validates the language model output and remediates errors by providing feedback to the model if errors are encountered during json parsing or during Pydantic model validation.<p>Six examples are provided for different types of unstructured data, including nested data.