Skip to main content

A Python SDK for interacting with Docling Serve API using Pydantic models

Project description

docling-serve-client

Python SDK for Docling Serve API v1.14.0

Python PyPI License: MIT

What is Docling Serve?

Docling Serve is an open-source REST API by IBM Research that converts PDFs, DOCX, PPTX, HTML, images, and other document formats into structured output — Markdown, JSON, HTML, or plain text. This SDK provides a fully typed Python client with sync and async support, automatic retries, chunking, and async task management.

Installation

pip install docling-serve-client

# With development dependencies
pip install "docling-serve-client[dev]"

Quick Start

from docling_serve_sdk import (
    DoclingClient,
    ConvertDocumentsRequest,
    ConvertDocumentsRequestOptions,
    HttpSourceRequest,
    OutputFormat,
)

with DoclingClient("http://localhost:5001") as client:
    # Health check
    health = client.health_check()
    print(health.status)  # "ok"

    # Convert a URL to Markdown
    request = ConvertDocumentsRequest(
        sources=[HttpSourceRequest(url="https://arxiv.org/pdf/2408.09869")],
        options=ConvertDocumentsRequestOptions(to_formats=[OutputFormat.MD]),
    )
    result = client.convert_source(request)
    print(result.document.md_content)

Features

  • Sync and async HTTP — built on httpx, every method has an _async variant
  • Fully typed Pydantic v2 models — all request and response types are validated at construction time
  • Retry with exponential backoff + jitter — transient 5xx and connection errors are retried automatically
  • Async task lifecycle — submit, poll, wait, and retrieve results for long-running conversions
  • Hybrid chunking — split documents using HybridChunkerOptions with configurable token limits
  • Hierarchical chunking — split documents using HierarchicalChunkerOptions with heading-aware segmentation
  • Event hookson_request, on_response, on_error callbacks for telemetry and logging
  • Request ID tracking — every HTTP request carries a unique X-Request-ID header for distributed tracing
  • Context manager supportwith and async with for deterministic connection pool lifecycle
  • S3 source and targetS3SourceRequest and S3Target with SecretStr credential handling (redacted in logs)
  • ZIP and in-body output targetsZipTarget for archives, InBodyTarget for inline JSON responses
  • Forward-compatible responses — response models use extra="allow" to tolerate new server fields
  • Strict requests — request models use extra="forbid" to catch typos at construction time
  • API key authentication — sent via X-Api-Key header, redacted in repr()

Compatibility

SDK version Docling Serve API Python Dependencies
1.14.0 v1.14.0 >=3.8.1 httpx>=0.24.0, pydantic>=2.0.0

The SDK version tracks the Docling Serve API version. When Docling Serve releases v1.15.0, the SDK will be updated to 1.15.0.

Running Tests

# Unit tests (no server needed)
pytest tests/test_sdk.py -v

# Integration tests (requires Docling Serve on localhost:5001)
pytest tests/test_integration.py -v

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docling_serve_client-1.14.0.tar.gz (30.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docling_serve_client-1.14.0-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file docling_serve_client-1.14.0.tar.gz.

File metadata

  • Download URL: docling_serve_client-1.14.0.tar.gz
  • Upload date:
  • Size: 30.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for docling_serve_client-1.14.0.tar.gz
Algorithm Hash digest
SHA256 4ae26910783edb06db4f4aa5d93352a6ce99cbae3e5077cbbad9160f3018ac9d
MD5 1552a7c084a35fa390d738d5a2deadc8
BLAKE2b-256 363e46d9095355ca24ba4c8dd2b8c5cb6018889a77d193ec920782cf1d89b064

See more details on using hashes here.

File details

Details for the file docling_serve_client-1.14.0-py3-none-any.whl.

File metadata

File hashes

Hashes for docling_serve_client-1.14.0-py3-none-any.whl
Algorithm Hash digest
SHA256 64c90924694e823449c191a4ce3b5c362a0eb9df941e70a89287fe90700f4892
MD5 c8ea493cc9564cb80916ab7aa11be75b
BLAKE2b-256 657287e5ae0f611df65e4736409357617a47061078f731f08fca27bc7ed6b494

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page