Skip to main content

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 by wait_for_job when the job ends in failed)

Project details


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.1.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stratum_client-0.1.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file stratum_client-0.1.1.tar.gz.

File metadata

  • Download URL: stratum_client-0.1.1.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stratum_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 a35df0bb3f5ed7b9be60ed0d143646399d1a3c89d8319300b01e35f3b214017a
MD5 d3de9b1dc259ee2a9d3ccd7c23820818
BLAKE2b-256 d632a3bd024f37732f2baa4304e23f2a11ebe5156ec1fe3f2cfe8614724bc01b

See more details on using hashes here.

Provenance

The following attestation bundles were made for stratum_client-0.1.1.tar.gz:

Publisher: publish-python-client.yml on Pleias/stratum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file stratum_client-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: stratum_client-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for stratum_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 51d84d1be62b5c608922162885911246e910c0db0d6895051b4741f7546dd274
MD5 8d4e3ef6f1dea45fcca0f3464fc772cd
BLAKE2b-256 a89950daf7e706dc19f46eb92920e05f22ec41895a141b4b415a49efff6450c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for stratum_client-0.1.1-py3-none-any.whl:

Publisher: publish-python-client.yml on Pleias/stratum

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page