Skip to main content

structx-llm (DEPRECATED)

This package is deprecated and has been renamed to structx.

All future releases and support are under the new name. Installing structx-llm will automatically install structx as a dependency.

Migration:

  • Update your requirements to use structx instead of structx-llm
  • For extras, use structx[docs], structx[pdf], structx[docx]
pip uninstall -y structx-llm
pip install -U structx

Advanced structured data extraction from any document using LLMs with multimodal support.

Documentation PyPI GitHub Actions

structx is a powerful Python library for extracting structured data from any document or text using Large Language Models (LLMs). It features an innovative multimodal PDF processing pipeline that converts any document to PDF and uses instructor's vision capabilities for superior extraction quality.

✨ Key Features

🎯 Advanced Document Processing

  • � Multimodal PDF Pipeline: Converts any document (TXT, DOCX, etc.) to PDF for optimal extraction
  • 🖼️ Vision-Enabled Extraction: Native instructor multimodal support for PDFs and images
  • 🔄 Smart Format Detection: Automatic processing mode selection for best results
  • 📊 Universal File Support: CSV, Excel, JSON, Parquet, PDF, DOCX, TXT, Markdown, and more

🚀 Intelligent Data Extraction

  • 🔄 Dynamic Model Generation: Create type-safe Pydantic models from natural language queries
  • 🎯 Automatic Schema Inference: Intelligent schema generation and refinement
  • 📊 Complex Data Structures: Support for nested and hierarchical data
  • 🔄 Natural Language Refinement: Improve models with conversational instructions

⚡ Performance & Reliability

  • 🚀 High-Performance Processing: Multi-threaded and async operations
  • 🔄 Robust Error Handling: Automatic retry mechanism with exponential backoff
  • 📈 Token Usage Tracking: Detailed step-by-step metrics for cost monitoring
  • � Flexible Configuration: Configurable extraction using OmegaConf
  • 🔌 Multiple LLM Providers: Support through litellm integration

Installation

# Core package with basic extraction capabilities
pip install structx-llm

📄 Enhanced Document Processing (Recommended)

For the best experience with all document types including advanced multimodal PDF processing:

# Complete document processing support
pip install structx-llm[docs]

# Individual components
pip install structx-llm[pdf]   # PDF processing with multimodal support
pip install structx-llm[docx]  # Advanced DOCX conversion via docling

🔧 What Each Extra Provides

  • [docs]: Complete multimodal document processing pipeline

    • PDF conversion from any document type
    • Instructor multimodal vision support
    • Advanced DOCX processing via docling
    • Enhanced extraction quality
  • [pdf]: PDF-specific processing

    • Multimodal PDF support via instructor
    • PDF generation capabilities
    • Basic PDF text extraction fallback
  • [docx]: Advanced DOCX support

    • Document conversion via docling
    • Structure preservation
    • Markdown-based processing pipeline

Quick Start

Basic Text Extraction

from structx import Extractor

# Initialize extractor
extractor = Extractor.from_litellm(
    model="gpt-4o",
    api_key="your-api-key",
    max_retries=3,      # Automatically retry on transient errors
    min_wait=1,         # Start with 1 second wait
    max_wait=10         # Maximum 10 seconds between retries
)

# Extract from text
result = extractor.extract(
    data="System check on 2024-01-15 detected high CPU usage (92%) on server-01.",
    query="extract incident date and details"
)

# Access results
print(f"Extracted {result.success_count} items")
print(result.data[0].model_dump_json(indent=2))

📄 Document Processing with Multimodal Support

# Process a PDF invoice directly with vision capabilities
result = extractor.extract(
    data="scripts/example_input/S0305SampleInvoice.pdf",      # Direct multimodal processing
    query="extract the invoice number, total amount, and line items"
)

# Convert a DOCX contract and process with multimodal support
result = extractor.extract(
    data="scripts/example_input/free-consultancy-agreement.docx", # Auto-converted to PDF -> multimodal
    query="extract parties, effective date, and payment terms"
)

📊 Token Usage Monitoring

# Check token usage for cost monitoring
usage = result.get_token_usage()
if usage:
    print(f"Total tokens: {usage.total_tokens}")
    print(f"By step: {[(s.name, s.tokens) for s in usage.steps]}")

🚀 Why Multimodal PDF Processing?

The innovative multimodal approach provides significant advantages over traditional text-based extraction:

  • 📄 Context Preservation: Full document layout and structure are maintained
  • 🎯 Higher Accuracy: Vision models can interpret tables, charts, and complex layouts
  • 🔄 No Chunking Issues: Eliminates problems with information split across chunks
  • 📊 Universal Format: Any document type becomes processable through PDF conversion
  • 🖼️ Visual Understanding: Handles documents with visual elements, formatting, and structure

📚 Documentation

For comprehensive documentation, examples, and guides, visit our documentation site.

Examples

Check out our example gallery for real-world use cases,

📁 Supported File Formats

📊 Structured Data (Direct Processing)

  • CSV: Comma-separated values with custom delimiters
  • Excel: .xlsx/.xls with sheet selection and custom options
  • JSON: JavaScript Object Notation with nested support
  • Parquet: Columnar storage format for large datasets
  • Feather: Fast binary format for data frames

📄 Unstructured Documents (Multimodal Pipeline)

Format Extensions Processing Method Quality
PDF .pdf Direct multimodal processing ⭐⭐⭐⭐⭐
Word .docx, .doc Docling → Markdown → PDF → Multimodal ⭐⭐⭐⭐⭐
Text .txt, .md, .py, .log, .xml, .html Styled PDF → Multimodal ⭐⭐⭐⭐

🔄 Processing Modes

  • Multimodal PDF (default): Best quality, preserves layout and context
  • Simple Text: Fallback mode with chunking for memory-constrained environments
  • Simple PDF: Basic PDF text extraction without vision capabilities

Contributing

Contributions are welcome! Please read our Contributing Guidelines for details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for structx-llm 0.4.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for structx-llm 0.4.9
File Size Uploaded Provenance Actions
structx_llm-0.4.9.tar.gz 38.5 kB With provenance Details for structx_llm-0.4.9.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for structx-llm 0.4.9
File Interpreter ABI Platform Actions
structx_llm-0.4.9-py3-none-any.whl Python 3 none any Details for structx_llm-0.4.9-py3-none-any.whl

Total release size: 81.2 kB

Release files / structx_llm-0.4.9.tar.gz

Download URL structx_llm-0.4.9.tar.gz
Size 38.5 kB
Tags Source
SHA-256 checksum
How to use checksums
ec996d7a8bee226f4d1232706591a97a5d82be3cdf8559a8d28e64e271c7959a
BLAKE2b-256 checksum
How to use checksums
b4c14cce569d590785e6bb086cac926a6e0da8fa3dc30920444b9128a9c1c632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2025.

Transparency log

Release files / structx_llm-0.4.9-py3-none-any.whl

Download URL structx_llm-0.4.9-py3-none-any.whl
Size 42.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d71084cc9d6d9dbba278c45e56d5ee976def75367b3080d9d4d630c6d0c0f4e1
BLAKE2b-256 checksum
How to use checksums
0ca4c776cd8e73d1e5778f74d3c4a5c8e258217a20cb0a9126c7e59284948897
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2025.

Transparency log

Security for structx-llm 0.4.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for structx_llm-0.4.9.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page