In this section, we will see how to use the methods of the documents client.

Create Messages

create_messages
Function

Creates messages from a document for use with LLM models

Response
DocumentMessage Object

A DocumentMessage object with the messages created from the document.

Use doc_msg.items to have a list of [PIL.Image.Image | str] objects

Correct image orientation

correct_image_orientation
function

Corrects the orientation of an image using the UiForm API.

Response
PIL.Image.Image

The orientation-corrected image as a PIL Image object

Extractions

extractions.parse

extractions.parse
function

Extract structured data from a document using a JSON schema

Response
ParsedChatCompletion

An OpenAI ParsedChatCompletion object with the extracted data.

extractions.stream

extractions.stream
function

Extract structured data from a document using a JSON schema

Response
AsyncChatCompletionStreamManager[ResponseFormatT]

An OpenAI AsyncChatCompletionStreamManager[ResponseFormatT] object with the extracted data.