from unstructured_client import UnstructuredClient
from unstructured_client.models import shared
from unstructured_client.models.errors import SDKError
client = UnstructuredClient(
api_key_auth="YOUR_API_KEY",
# you may need to provide your unique API URL
# server_url="YOUR_API_URL",
)
filename = "sample-docs/layout-parser-paper.pdf"
file = open(filename, "rb")
req = shared.PartitionParameters(
# Note that this currently only supports a single file
files=shared.Files(
content=file.read(),
file_name=filename,
),
# Other parameters
strategy="fast",
)
try:
res = client.general.partition(req)
print(res.elements[0])
except SDKError as e:
print(e)