Python SDK

The official ivorleaf Python SDK v0.1.0 wraps the Validation Intelligence POST/GET API. Python 3.10–3.14 is supported. Its only direct runtime dependency is HTTPX.

Pilot installation

This version is pilot/repository-distributed and not published to PyPI. Install the wheel supplied by the Ivorleaf team:

python -m pip install ./ivorleaf-0.1.0-py3-none-any.whl

Or run python -m pip install . from the supplied SDK checkout. No public repository destination is established here. Package-index publication is a separate release action.

First validation

Set IVORLEAF_API_KEY securely in your environment or secret manager. An explicit Ivorleaf(api_key="...") overrides the environment; never commit the key.

from ivorleaf import Ivorleaf

with Ivorleaf() as client:
    result = client.validation.create(
        information="H2O is the chemical formula for water.",
        evidence=[{"text": "The chemical formula for water is H2O."}],
    )
    print(result.validation_id, result.determination)
    print(result.relationships)

Expected for this simple example: supported with a supports relationship. result.to_dict() preserves the canonical public response, including information units, evidence, reason, signals and provenance. No confidence score is added.

Input compatibility

The inspected v0.1.0 client vendors an older request schema requiring evidence text. It can reject URL-only/null-text evidence locally even though production REST and Web accept those forms. Confirm your supplied distribution before using URL-only or mixed requests. Use ordinary HTTP for current forms; no new SDK release is claimed here.

Source-backed evidence

with Ivorleaf() as client:
    result = client.validation.create(
        information="Government TLS servers and clients are required to support TLS 1.2 configured with FIPS-based cipher suites.",
        evidence=[{
            "text": "NIST SP 800-52 Rev. 2 requires TLS 1.2 configured with FIPS-based cipher suites to be supported by all government TLS servers and clients.",
            "source": {
                "title": "NIST SP 800-52 Rev. 2 — Guidelines for TLS Implementations",
                "url": "https://csrc.nist.gov/pubs/sp/800/52/r2/final",
            },
        }],
    )

The server performs Source Inspection. Inspected material is authoritative; evidence.text is a retrieval hint and cannot override it. Inspection failure fails closed. The SDK preserves source metadata and never fetches evidence URLs locally. Private/authenticated source retrieval is not promised by v1.

Automatic 202 → GET handling

create() sends Prefer: respond-async by default. HTTP 200 returns the completed result; HTTP 202 triggers GET polling of the same validation ID to a terminal state. Retry-After is respected with a minimum/fallback one-second interval. No automatic POST or semantic retries occur.

The default SDK wait budget is 120 seconds, configurable with Ivorleaf(wait_timeout=120). It includes the initial POST and subsequent polling. It is distinct from the server's 20s sync / 60s provider / 90s hard budgets. Network inactivity timeouts and deadline checks apply; this is not hard real-time cancellation.

Retrieve, wait and recovery

from ivorleaf.errors import IvorleafWaitTimeout, IvorleafUnknownOutcomeError

with Ivorleaf() as client:
    state = client.validation.retrieve("YOUR_VALIDATION_ID")  # one GET
    result = client.validation.wait("YOUR_VALIDATION_ID")     # GET until terminal

retrieve() returns completed, in_progress or failed typed states. create() and wait() raise ValidationExecutionError on terminal failure, with validation_id and public code/message. An SDK wait timeout preserves validation_id: the server may still be running, so retrieve or wait later.

For create, supply a durable idempotency_key="workflow-event-123" or let the SDK generate one, exposed as result.idempotency_key. Unknown POST outcome raises IvorleafUnknownOutcomeError carrying the effective idempotency_key. Explicit recovery must preserve the same key and payload. Never blindly create again with a new key. Store a caller-chosen key before sending if crash recovery is required.

Typed HTTP errors cover 401, 403, 404, 409, 422, 429 and 500/502/503/504; see errors and idempotency. All SDK exceptions inherit ivorleaf.errors.IvorleafError.

JSON file input

with Ivorleaf() as client:
    result = client.validation.create_from_file("validation-request.json")

One regular UTF-8 .json file maps to one exact ValidationRequest. Arrays, unknown request fields, blank required text, Markdown and URL retrieval are rejected. The filename does not enter idempotency. Use the canonical JSON examples.