Official Python client for the Stratum document-chunking API.
Project description
stratum-client (Python)
Official Python client for the Stratum document-chunking API.
pip install stratum-client
Quick start
from stratum_client import Client, JobConfig
client = Client(api_key="stratum_xxxxxxxx_...") # or set STRATUM_API_KEY
job = client.submit_job(
"report.pdf",
config=JobConfig(target_size=500, enrichments=["summary"]),
)
result = client.wait_for_job(job.id)
for chunk in result["chunks"]:
print(chunk["text"])
Client
Client(
api_key: str | None = None, # falls back to $STRATUM_API_KEY
base_url: str = "https://api-stratum.pleias.dev",
timeout: float = 60.0,
)
Methods:
| Method | Description |
|---|---|
healthz() / readyz() |
Liveness / readiness probes |
submit_job(file, *, config=None, project_id=None) |
Upload a document and create a job |
get_job(job_id) |
Fetch a single job |
list_jobs(*, page=1, page_size=20, status=None, project_id=None) |
Paginated job list |
iter_jobs(*, page_size=50, status=None, project_id=None) |
Iterate every job, auto-paging |
get_job_result(job_id) |
Download the chunker output (dict matching docs/output-format.md) |
cancel_job(job_id) |
Delete a job and its storage artifacts |
wait_for_job(job_id, *, poll_interval=2.0, timeout=None) |
Poll until done; returns the result |
Client is also a context manager: with Client(...) as c: ....
Errors
All errors derive from StratumError:
AuthenticationError(401/403)NotFoundError(404)JobNotCompleteError(409 — result requested before job finished)ApiError(other non-2xx)JobFailedError(raised bywait_for_jobwhen the job ends infailed)
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
stratum_client-0.1.0.tar.gz
(12.2 kB
view details)
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 stratum_client-0.1.0.tar.gz.
File metadata
- Download URL: stratum_client-0.1.0.tar.gz
- Upload date:
- Size: 12.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
662748e6632d08f74568d6539d2efc3bc320dc8103684b211c1bdaacb5279470
|
|
| MD5 |
535024b06c966d8f0b571145f6413b23
|
|
| BLAKE2b-256 |
b4f1d6d6c923d860aeeedc95266578390a16a292b939c75be2742f33b20e020b
|
File details
Details for the file stratum_client-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stratum_client-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e073710235eb8eb39ba2611117979906b876fd6a71c3c3d479bdbf52d90113b
|
|
| MD5 |
81ce198bf8c2b41f591246f515ecb5da
|
|
| BLAKE2b-256 |
b280bf5017d546924b12950fd8253b283098fc4a4e21a9d6532680471d8a9449
|