docling_rs
An unofficial, typed, async-first Rust SDK for Docling Serve — the document conversion API powered by IBM's Docling.
Convert PDFs, DOCX, PPTX, images, and more into Markdown, JSON, HTML, or plain text from Rust.
Features
- Synchronous & async conversion — block until done, or submit and poll
- Local file upload — convert files from disk via multipart upload
- Fully typed — all enums, options, and responses match the OpenAPI 3.1 spec (v1.12.0)
- Optional API key auth —
Authorization: Bearer <key>on all secured endpoints - Structured errors — distinct variants for network, API, deserialization, file I/O, task failure, and timeout
- Zero unsafe code
Requirements
- Rust 2024 edition (1.85+)
- A running Docling Serve instance
Installation
Add to your Cargo.toml:
[]
= { = "." }
= { = "1", = ["macros", "rt-multi-thread"] }
Quick Start
Health check
use DoclingClient;
async
Convert a URL to Markdown (synchronous)
use DoclingClient;
async
Convert with options
use ;
async
Async conversion with polling
For large documents, use async conversion to avoid HTTP timeouts:
use Duration;
use DoclingClient;
async
Manual async flow (fine-grained control)
use DoclingClient;
async
Convert a local file
use DoclingClient;
async
Async file conversion with polling
use Duration;
use DoclingClient;
async
With API key authentication
use DoclingClient;
let client = with_api_key;
API Reference
DoclingClient
| Method | Endpoint | Description |
|---|---|---|
health() |
GET /health |
Health check |
version() |
GET /version |
Server version info |
convert_source(url, options) |
POST /v1/convert/source |
Synchronous URL conversion |
convert(request) |
POST /v1/convert/source |
Full request control |
convert_source_async(url, options) |
POST /v1/convert/source/async |
Submit async URL task |
convert_async(request) |
POST /v1/convert/source/async |
Submit async (full request) |
convert_file(paths, options, target) |
POST /v1/convert/file |
Synchronous file upload |
convert_file_async(paths, options, target) |
POST /v1/convert/file/async |
Submit async file task |
poll_task_status(task_id, wait) |
GET /v1/status/poll/{id} |
Poll task status |
get_task_result(task_id) |
GET /v1/result/{id} |
Fetch completed result |
wait_for_conversion(url, opts, timeout, poll) |
(composite) | Submit URL + poll + fetch |
wait_for_file_conversion(paths, opts, tgt, timeout, poll) |
(composite) | Submit file + poll + fetch |
Key Types
Enums:
InputFormat, OutputFormat, ImageRefMode, TableFormerMode, PdfBackend, ProcessingPipeline, OcrEngine, ConversionStatus, VlmModelType
Request:
Source (Http, File), Target (InBody, Zip), ConvertDocumentsRequestOptions, ConvertDocumentsRequest
Response:
ConvertDocumentResponse, ExportDocumentResponse, TaskStatusResponse, HealthCheckResponse
Errors:
DoclingError — Http, Api, Json, Io, TaskFailed, Timeout
Conversion Options
All fields in ConvertDocumentsRequestOptions are optional. The server applies defaults for anything omitted. Key options:
| Field | Type | Default | Description |
|---|---|---|---|
to_formats |
Vec<OutputFormat> |
["md"] |
Output format(s) |
do_ocr |
bool |
true |
Enable OCR |
ocr_engine |
OcrEngine |
easyocr |
OCR engine |
table_mode |
TableFormerMode |
accurate |
Table extraction mode |
pdf_backend |
PdfBackend |
dlparse_v4 |
PDF parser backend |
pipeline |
ProcessingPipeline |
standard |
Processing pipeline |
page_range |
(i64, i64) |
(1, MAX) |
Page range to convert |
image_export_mode |
ImageRefMode |
embedded |
How to handle images |
See ConvertDocumentsRequestOptions for the full list (25+ fields).
Running Examples
Start Docling Serve:
Run examples:
Error Handling
use ;
async
Testing
Run the full test suite (no running Docling Serve instance required):
The suite includes 79 tests across serialization round-trips, mock HTTP client behavior, auth header handling, file uploads, error mapping, and more.
License
MIT