Python SDK for the kaval currentness API — sync client, 30s default timeout, no automatic retries.
Project description
kaval (Python SDK)
The freshness gate for AI. Give kaval a belief your system
already holds — a cached fact, a CRM field, an agent memory — and it checks the live world and
returns a typed freshness gap: current / stale / contradicted / unsupported / conflicting
/ insufficient.
Install
pip install kaval
Async / concurrency
Sync-only for now. KavalClient is built on httpx.Client (blocking I/O). v0.1.x does not ship
an AsyncKavalClient — if you need async/await, call the REST API with httpx.AsyncClient, wrap
sync calls in asyncio.to_thread(), or use the Node SDK (@usekaval/kaval). Native async may land
in a later release.
Gate a belief before you act on it
from kaval import KavalClient
# Explicit config (always works):
with KavalClient(api_key="kv_live_...") as client:
decision = client.verify("Acme's CEO is Jane Doe")
if not decision["act"]:
... # stale / contradicted — re-fetch before relying on it
# Or set env vars and construct with no args (see below):
# export KAVAL_API_KEY=kv_live_...
# export KAVAL_BASE_URL=https://api.usekaval.com # optional; defaults to prod
with KavalClient() as client:
...
verify() returns the verdict plus act — True only when the belief is current and confident
(≥ 0.7 by default; override with min_confidence).
Pick a speed/depth tier
verify(belief, mode=...) selects a tier (default auto): instant (cache / graph-prior only, no
fetch or LLM), fast (cheap model, origin-only), auto (balanced), or deep (strongest model + a
cited explanation). The returned dict echoes tier, and on the deep tier adds explanation:
gap = client.verify("Acme's CEO is Jane Doe", mode="deep")
gap["tier"] # "deep"
gap["explanation"]["content"] # markdown rationale with [n] citations (deep only)
gap["explanation"]["citations"] # [{"url": ..., "title"?: ...}] — only from gathered evidence
gap["explanation"]["confidence"] # "high" | "medium" | "low"
Sweep a store for drift
beliefs = ["Acme is on the Enterprise plan", "Jane Doe is VP Eng at Acme"]
report = client.scan_store(beliefs)
for r in report["riskiest"]:
print(r["belief"], "→", r["status"])
# …or get pushed the newly-stale ones (carry `state` across runs so a still-stale belief
# isn't re-delivered every sweep):
client.monitor(beliefs, webhook="https://your-app.com/hooks/stale")
Custom base URL
Override the API base URL (e.g. a staging environment or a local proxy):
client = KavalClient(base_url="https://staging.api.usekaval.com", api_key="...")
Environment variables
When omitted, constructor args fall back to:
| Variable | Used for | Default |
|---|---|---|
KAVAL_API_KEY |
Bearer token | none (unauthenticated) |
KAVAL_BASE_URL |
API origin | https://api.usekaval.com |
The marketing site (apps/web) uses KAVAL_API_URL for its server-side proxy — not
KAVAL_BASE_URL. Set both when self-hosting the engine and running the web demo against it.
Explicit api_key= / base_url= always wins over the environment.
Resilience
No automatic retries by default — bring your own. Each API call is a single HTTP round-trip via
httpx; transient failures (timeouts, 502s, rate limits) are not retried. Wrap calls in your own
retry/backoff (e.g. tenacity) if you need that behavior.
Default timeout: 30 seconds (connect + read), overridable at construction:
# deep verify / scan sweeps may run close to the limit — raise for long-running calls:
client = KavalClient(api_key="...", timeout=60.0)
Timeouts surface as httpx.TimeoutException (not KavalError).
API
verify · check · extract_and_check · scan_store · monitor · report_outcome ·
kaval · kaval_batch · health. Construct with KavalClient(base_url=?, api_key=?) —
base_url defaults to https://api.usekaval.com. The Node/TypeScript client mirrors this surface:
npm install @usekaval/kaval.
Test
pip install -e ".[dev]" # from sdks/python (development)
pytest # hermetic contract tests (httpx MockTransport)
KAVAL_BASE_URL=https://api.usekaval.com KAVAL_API_KEY=kv_live_... pytest # also runs the live test
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
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 kaval-0.1.3.tar.gz.
File metadata
- Download URL: kaval-0.1.3.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e39135ba8fc21606b64b97946cb78be5a76f7f7360a3ae713f8aa5ed972a1e7
|
|
| MD5 |
1b9355695843313c1528adccdd523411
|
|
| BLAKE2b-256 |
03e7fb0bc202c1b5c3abb1f4b990f6cd2890a38d761c58a3706a14eba6c7aa62
|
Provenance
The following attestation bundles were made for kaval-0.1.3.tar.gz:
Publisher:
release.yml on LufeMC/kaval-clients
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kaval-0.1.3.tar.gz -
Subject digest:
0e39135ba8fc21606b64b97946cb78be5a76f7f7360a3ae713f8aa5ed972a1e7 - Sigstore transparency entry: 2014711072
- Sigstore integration time:
-
Permalink:
LufeMC/kaval-clients@e57e11088705dfba21bf3e65ca249ead74b6759b -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/LufeMC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e57e11088705dfba21bf3e65ca249ead74b6759b -
Trigger Event:
push
-
Statement type:
File details
Details for the file kaval-0.1.3-py3-none-any.whl.
File metadata
- Download URL: kaval-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
439867873e8473b84a2f714a8e12c7a678c90b9e5e4fd5f215cb0512f9e34eb7
|
|
| MD5 |
a4a6a51eeff97f786a0f08a164d76f96
|
|
| BLAKE2b-256 |
84d535485f20384a253e9a093977e304def310e51efea4429145ac504aa57618
|
Provenance
The following attestation bundles were made for kaval-0.1.3-py3-none-any.whl:
Publisher:
release.yml on LufeMC/kaval-clients
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
kaval-0.1.3-py3-none-any.whl -
Subject digest:
439867873e8473b84a2f714a8e12c7a678c90b9e5e4fd5f215cb0512f9e34eb7 - Sigstore transparency entry: 2014711139
- Sigstore integration time:
-
Permalink:
LufeMC/kaval-clients@e57e11088705dfba21bf3e65ca249ead74b6759b -
Branch / Tag:
refs/tags/v0.1.3 - Owner: https://github.com/LufeMC
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e57e11088705dfba21bf3e65ca249ead74b6759b -
Trigger Event:
push
-
Statement type: