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
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
_asyncvariant - 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
HybridChunkerOptionswith configurable token limits - Hierarchical chunking — split documents using
HierarchicalChunkerOptionswith heading-aware segmentation - Event hooks —
on_request,on_response,on_errorcallbacks for telemetry and logging - Request ID tracking — every HTTP request carries a unique
X-Request-IDheader for distributed tracing - Context manager support —
withandasync withfor deterministic connection pool lifecycle - S3 source and target —
S3SourceRequestandS3TargetwithSecretStrcredential handling (redacted in logs) - ZIP and in-body output targets —
ZipTargetfor archives,InBodyTargetfor 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-Keyheader, redacted inrepr()
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ae26910783edb06db4f4aa5d93352a6ce99cbae3e5077cbbad9160f3018ac9d
|
|
| MD5 |
1552a7c084a35fa390d738d5a2deadc8
|
|
| BLAKE2b-256 |
363e46d9095355ca24ba4c8dd2b8c5cb6018889a77d193ec920782cf1d89b064
|
File details
Details for the file docling_serve_client-1.14.0-py3-none-any.whl.
File metadata
- Download URL: docling_serve_client-1.14.0-py3-none-any.whl
- Upload date:
- Size: 23.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
64c90924694e823449c191a4ce3b5c362a0eb9df941e70a89287fe90700f4892
|
|
| MD5 |
c8ea493cc9564cb80916ab7aa11be75b
|
|
| BLAKE2b-256 |
657287e5ae0f611df65e4736409357617a47061078f731f08fca27bc7ed6b494
|