How landing-ai/ade-python works
1. What this repo is
- This is a generated Python SDK (landingai-ade) for the LandingAI Agentic Document Extraction REST API.
- It is not an application server; the main runtime boundary is: your Python code → SDK client → HTTPS API.
2. Public entrypoints
- The package’s public surface is exposed from src/landingai_ade/__init__.py.
- The README shows two primary client variants: LandingAIADE (sync) and AsyncLandingAIADE (async), plus HTTP client adapters such as DefaultHttpxClient and DefaultAioHttpClient.
3. Client architecture
- The core client stack lives in src/landingai_ade/_base_client.py, src/landingai_ade/_client.py, and src/landingai_ade/_resource.py.
- This layer owns request construction, base URL/environment selection, authentication, retries, timeouts, and routing method calls to endpoint-specific resources.
- The design is split into sync and async implementations with the same API shape.
4. API surface / endpoint grouping
- Endpoint-specific operations are organized as resource modules under src/landingai_ade/resources/.
- The repo tree shows parse_jobs.py, which handles the long-running document processing job flow: create job, fetch status, and list jobs.
- Other high-level operations from the README—parse, split, extract—are represented through client methods and associated request/response types.
5. HTTP and response handling
- src/landingai_ade/_response.py and src/landingai_ade/_streaming.py define how raw HTTP responses are wrapped, parsed, streamed, and optionally exposed to callers.
- This is where the SDK separates:
- eager parsing of JSON responses,
- raw-response access for headers/status,
- streaming response access for large payloads or incremental reads.
6. Request serialization and file upload path
- src/landingai_ade/_files.py, _qs.py, and _utils/_transform.py handle turning Python inputs into HTTP-friendly payloads.
- This matters because the SDK accepts:
- local paths / bytes / multipart tuples for file uploads,
- nested typed request objects,
- query parameters and extra headers/body fields.
- The library abstracts away the multipart and encoding details before the request reaches the API.
7. Type system and response models
- Runtime models and typed request/response contracts live in src/landingai_ade/_models.py and src/landingai_ade/types/.
- Responses are Pydantic models; request params are mostly TypedDict-style structures.
- The types/shared/ folder captures shared schema fragments such as metadata and grounding boxes, which suggests common response shapes reused across parse/extract flows.
8. Domain helpers
- src/landingai_ade/lib/schema_utils.py and url_utils.py provide SDK-specific helpers for schema conversion and URL handling.
- The README’s extraction example uses Pydantic model → JSON Schema conversion before sending data to the API, so schema handling is an important boundary in the extraction flow.
9. Utility layer
- src/landingai_ade/_utils/ contains cross-cutting support code for:
- datetime parsing,
- JSON encoding/decoding,
- logging,
- path and stream helpers,
- sync/async compatibility,
- typing and reflection helpers.
- These utilities keep the endpoint code thin and centralize compatibility behavior across Python versions and async/sync modes.
10. Error and retry model
- src/landingai_ade/_exceptions.py defines the SDK’s error taxonomy, mapping HTTP failures and connection issues into typed exceptions.
- The README’s retry behavior is implemented in the client layer: connection errors, timeouts, rate limits, conflicts, and server errors are retried with exponential backoff.
- This is a key operational boundary between user code and the API.
11. Testing strategy
- tests/ is organized by concern: client behavior, resources, response handling, streaming, files, model serialization, query strings, transforms, and utility functions.
- The tests mirror the architecture of the SDK rather than the API domain, which is typical for a generated library: they validate transport behavior, type handling, and endpoint wrappers.
12. Packaging, release, and developer tooling
- The repo is packaged with pyproject.toml and ships py.typed, so type information is part of the distribution.
- CI and release automation live in .github/workflows/, with separate workflows for CI, PyPI publish, and release checks.
- Local/dev tooling includes noxfile.py, scripts for lint/format/test/bootstrap, and release-please metadata, indicating a strongly automated library release pipeline.
13. Overall data flow
- Typical flow is: caller constructs client → client serializes params/files → HTTP request goes to LandingAI ADE REST API → response is wrapped/validated by Pydantic models → caller consumes parsed data or raw/streaming response.
- For large documents, the flow shifts to async parse-job creation → polling via job endpoints → retrieval of status/list results, rather than a single synchronous request.
14. Architecture boundary to draw
- The most important boundary is the SDK boundary vs. the external REST API.
- Inside the repo, the architecture is a layered client library: public client API → resource methods → transport/response layer → utility/type/model layer.
- There is no internal service mesh or database; the only external dependency that materially shapes the architecture is the LandingAI ADE API over HTTP.
Main entry points: _base_client.py Base client · _client.py Sync client · _response.py Responses · parse_jobs.py Parse jobs
Components 19
SDK source
Generated client library and runtime helpers.
- Public API · Top-level package surface exposed from src/landingai_ade/__init__.py.
src/landingai_ade/__init__.py - Sync client · Synchronous LandingAIADE entrypoint and method surface.
src/landingai_ade/_client.py - Async client · AsyncLandingAIADE entrypoint with the same API shape as the sync client.
src/landingai_ade/_client.py - Base client · Shared request construction, auth, retries, timeout, and environment selection.
src/landingai_ade/_base_client.py - Resource base · Common resource wrapper that binds client methods to API endpoint groups.
src/landingai_ade/_resource.py - Parse jobs · Long-running document job operations: create, get status, and list.
src/landingai_ade/resources/parse_jobs.py - Responses · Raw, parsed, and streaming response handling around HTTP results.
src/landingai_ade/_response.py - Streaming · Incremental and large-payload response access.
src/landingai_ade/_streaming.py - Serialization · Query-string, multipart, file, and object-to-HTTP transformations.
src/landingai_ade/_files.py - Utilities · Datetime, JSON, logging, path, sync/async, reflection, and typing helpers.
src/landingai_ade/_utils - Schema helpers · Schema conversion and URL helpers used by extraction and request building.
src/landingai_ade/lib/schema_utils.py - Errors · Typed exceptions for HTTP failures, connection issues, and retries.
src/landingai_ade/_exceptions.py
Contracts
Typed request and response models used by the SDK.
- Models · Pydantic response models and supporting runtime model definitions.
src/landingai_ade/_models.py - Request types · Typed request parameter structures for parse, split, extract, and jobs.
src/landingai_ade/types - Response types · Typed response objects and shared schema fragments.
src/landingai_ade/types
Tests
Behavioral tests mirroring the client architecture.
- Client tests · Tests for client behavior, resources, response handling, and serialization.
tests/api_resources/test_client.py - Runtime tests · Tests for files, response, streaming, transforms, and utility helpers.
tests/test_response.py
Tooling
Packaging, CI, release, and local development automation.
- CI & release · Packaging, linting, testing, CI, and publish workflows.
pyproject.toml
Other components
- LandingAI ADE API · Remote HTTP boundary consumed by the SDK.
Connections 21
- Public API → Sync client: exports · Public package surface exposes the sync client.
- Public API → Async client: exports · Public package surface exposes the async client.
- Sync client → Base client: uses · Sync client delegates transport concerns to the shared base client.
- Async client → Base client: uses · Async client delegates transport concerns to the shared base client.
- Base client → Resource base: binds · Base client provides the machinery used by resource wrappers.
- Resource base → Parse jobs: implements · Resource layer exposes parse job endpoints.
- Parse jobs → Request types: accepts · Endpoint methods consume typed request payloads.
- Parse jobs → Response types: returns · Endpoint methods return typed response models.
- Sync client → Serialization: serializes · Client prepares files, query strings, and request bodies before send.
- Async client → Serialization: serializes · Async client shares the same payload transformation layer.
- Serialization → Utilities: uses · Serialization relies on shared helpers for encoding and transforms.
- Responses → Streaming: wraps · Response handling can expose streaming access.
- Responses → Models: parses · Parsed responses are validated into Pydantic models.
- Models → Response types: aligns · Runtime models correspond to typed response contracts.
- Schema helpers → Request types: supports · Schema conversion feeds extraction request construction.
- Base client → Responses: receives · Transport layer hands raw responses to the response wrapper.
- Base client → Errors: maps · HTTP and connection failures become typed SDK exceptions.
- Base client → LandingAI ADE API: calls · Client issues HTTPS requests to the LandingAI ADE API.
- Runtime tests → Responses: verifies · Tests cover response parsing and streaming behavior.
- Client tests → Sync client: verifies · Tests cover client routing and resource behavior.
- CI & release → Public API: ships · Packaging and release automation publish the SDK surface.