Docling Serve API Client#
Overview#
docling-serve-client is the reference Java HTTP client for connecting to a Docling Serve backend . It is part of the docling-java project, which provides a Java API for remote document processing.
The client-server architecture splits into two artifacts:
docling-serve-api— framework-agnostic interfaces and request/response model types (DoclingServeApi,ConvertDocumentRequest, etc.)docling-serve-client— concrete HTTP implementation ofDoclingServeApiusing Java's built-inHttpClientand Jackson
Framework users: If you are on Quarkus, use the Quarkus Docling extension. For Spring Boot, use Arconia. The standalone
docling-serve-clienttargets plain Java applications.
Architecture#
DoclingServeApi is an interface that composes five sub-APIs: DoclingServeHealthApi, DoclingServeConvertApi, DoclingServeChunkApi, DoclingServeClearApi, and DoclingServeTaskApi. The client implementation is resolved at runtime via Java SPI (ServiceLoader): if Jackson 3 is on the classpath, DoclingServeJackson3Client is used; otherwise DoclingServeJackson2Client is used.
Key Source Locations#
| Component | Path |
|---|---|
DoclingServeApi interface | docling-serve-api/.../DoclingServeApi.java |
ConvertDocumentRequest model | docling-serve-api/.../ConvertDocumentRequest.java |
| Client documentation | docs/src/doc/docs/docling-serve/serve-client.md |
| Docling Serve backend endpoints | docling_serve/app.py |
Backend API Endpoints#
The Docling Serve backend (Python/FastAPI) exposes the following endpoints relevant to the Java client :
| Endpoint | Method | Description |
|---|---|---|
/health | GET | Basic health check |
/ready, /readyz, /livez | GET | Kubernetes-style probes |
/v1/convert/source | POST | Synchronous conversion from URL(s) |
/v1/convert/file | POST | Synchronous conversion from uploaded files |
/v1/convert/source/async | POST | Async conversion, returns task ID |
/v1/convert/source/batch | POST | Batch async conversion |
/v1/status/poll/{task_id} | GET | Poll async task status |
/v1/status/ws/{task_id} | WebSocket | Real-time task status updates |
/v1/result/{task_id} | GET | Retrieve completed task result |
When using plain http:// (e.g., local dev), the client enforces HTTP/1.1 to avoid HTTP/2 downgrade issues with FastAPI.
Request / Response Model#
ConvertDocumentRequest has three fields:
sources— list ofSourceobjects; each can be anHttpSource(URL) orFileSource(base64-encoded file)options— aConvertDocumentOptionsobject controlling output format, OCR, images, etc.target— aTargetspecifying where results are delivered;nulldefaults to in-body response
Response types#
convertSource() returns a polymorphic ConvertDocumentResponse. Use getResponseType() to dispatch on the concrete type :
ResponseType | Concrete class | When used |
|---|---|---|
IN_BODY | InBodyConvertDocumentResponse | Default; result in response body |
ZIP_ARCHIVE | ZipArchiveConvertDocumentResponse | Result as zip |
PRE_SIGNED_URL | PreSignedUrlConvertDocumentResponse | Presigned download URL (requires Docling Serve ≥ v1.22.0) |
PRE_SIGNED_URL_RESPONSE | PreSignedUrlConvertResponse | Per-document artifact URLs |
Source types#
HttpSource— document at a URL, optionally with custom headersFileSource— base64-encoded bytes with a filename
Target types#
InBodyTarget— result in response body (default)PresignedUrlTarget— presigned download URLs; requires Docling Serve ≥ v1.22.0PutTarget— upload result to arbitrary storage via HTTP PUT
Configuration#
The builder accepts:
baseUrl(String | URI)— Docling Serve endpointhttpClientBuilder(HttpClient.Builder)— customize timeouts, proxy, TLSlogRequests()/logResponses()/prettyPrint()— diagnostic loggingapiKey(String)— optional API key authentication
Error Handling#
- Transport errors (DNS, TLS, timeout, connection reset) surface as standard Java exceptions from
HttpClient. - Structured conversion errors appear in the response body even when partial content is returned. On
InBodyConvertDocumentResponse, inspectgetErrors()for per-component error details.
Installation#
Add docling-serve-client (which transitively includes docling-serve-api) plus a Jackson 2 or 3 implementation.
// Gradle
dependencies {
implementation("ai.docling:docling-serve-client:<version>")
}
<!-- Maven -->
<dependency>
<groupId>ai.docling</groupId>
<artifactId>docling-serve-client</artifactId>
<version>VERSION</version>
</dependency>
See Maven Central for the current version. All published releases are tested weekly against all published Docling Serve versions.