ylemis — Python SDK for the Ylemis Trust Platform
One integration for all Ylemis guardrails: PII Shield (India-tuned PII detection/redaction, 98.68% F1, 0% false positives on the published benchmark), Injection Guard, and GroundCheck. Use them as one pipeline, swap in your own guards, or call any product on its own. Zero dependencies — stdlib only.
Try the models live, no sign-up · Docs · Free API key
pip install ylemis
30-second DPDP fix
You're piping customer data into an LLM. Under India's DPDP Act, personal data sent to a model provider is still your responsibility, and penalties for missing security safeguards go up to ₹250 crore. One line keeps Aadhaar, PAN and phone numbers out of the prompt:
from ylemis import TrustEngine
engine = TrustEngine(keys={"pii-shield": "sk_live_..."})
safe_prompt = engine.check_input(user_text).redacted_text # PII never leaves your app
llm_response = call_your_llm(safe_prompt)
The two hooks (full flow)
Guardrails belong at two points in the LLM lifecycle — before the prompt goes out, and after the answer comes back:
engine = TrustEngine(api_key="sk_live_...") # one key everywhere (or keys={...} per product)
inp = engine.check_input(prompt) # PII + injection, PRE-LLM
if inp.decision == "block":
... # your policy
response = call_your_llm(inp.redacted_text)
out = engine.check_output(response, docs=retrieved_docs) # PII + groundedness, POST-LLM
if out.decision == "allow":
return response
engine.scan(prompt=..., response=..., docs=...) is batch/audit sugar over both hooks.
Pipelines: use ours, bring your own, or mix
Every step is a guard with one method, check(text, context). Build the default chain, then
swap or drop steps. A guard you already run, such as a regex, an in-house classifier or another
vendor's SDK, becomes a step by wrapping a function.
from ylemis import TrustEngine, FunctionGuard
engine = TrustEngine(api_key="sk_live_...")
pipe = engine.pipeline() # input: PII Shield -> Injection Guard; output: PII Shield, GroundCheck
# Already have an injection filter? Keep it, use Ylemis for the rest:
pipe = pipe.replace("injection-guard", FunctionGuard("my-filter", lambda text: my_filter(text)))
pipe = pipe.without("groundcheck") # or drop a step
result = pipe.run(user_text, llm=call_your_llm, docs=retrieved_docs)
if result.blocked:
... # blocked input never reaches the LLM
answer = result.safe_response # response after output guards
- A function guard may return
True/False,"allow" | "review" | "block", or(decision, rewritten_text)if it redacts. Add a second parameter to receive context (e.g.docs,user_id). - Guards that rewrite text run first, in order. Detectors run in parallel on the original text.
- The strictest decision wins. A guard that raises blocks by default
(
Pipeline(on_error="review" | "raise")to change that). llmis any function from prompt to text: a hosted model API, a local model, or your own retry/fallback layer.- PII Shield in a pipeline redacts and continues (
pii_mode="redact"). Useengine.pipeline(pii_mode="enforce")to block on high-risk identifiers instead.
check_input / check_output below still work unchanged.
Error handling — errors are honest
The API never masks infra errors as billing errors. The SDK encodes that contract as types:
from ylemis import QuotaExceeded, RateLimited, ServiceBusy, InvalidAPIKey
try:
r = engine.pii.scan(text)
except QuotaExceeded: # 402 — genuinely out of quota, upgrade or wait for reset
...
except RateLimited: # 429 — slow down (see .retry_after)
...
except ServiceBusy: # 503 — transient; SDK already auto-retried per Retry-After
...
Requests are metered only on success — a ServiceBusy retry never double-bills.
Per-product access
engine.pii.scan(text, redaction_mode="mask") # mask | replace | drop | hash (keyed per account)
engine.pii.redact(text)
engine.pii.usage()
engine.injection.score(text)
engine.groundcheck.check(response, source=[...])
engine.health() # no-auth liveness, all three services
Products without a configured key are skipped by check_* (listed in report.skipped)
and raise MissingKey if called directly — so a PII-only key works fine today.
Development status
All three adapters are exact, verified against the deployed services, including a live end-to-end run with a single key across all three products.
python -m pytest # offline, no keys needed
The SDK is MIT-licensed client code. API access requires a Ylemis subscription and key from ylemis.com.
Metadata
Release files for ylemis 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ylemis-0.2.0.tar.gz | 22.4 kB | Without provenance | Details for ylemis-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ylemis-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ylemis-0.2.0-py3-none-any.whl |
Total release size: 41.2 kB
Release files / ylemis-0.2.0.tar.gz
| Download URL | ylemis-0.2.0.tar.gz |
|---|---|
| Size | 22.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1855bf8f868aac53aa4dc3f3b7db50365bacfc184cb48e289ca4ce053e2494e3
|
|
BLAKE2b-256 checksum How to use checksums |
1636a71768efff9c6ec36e14425ef6a538b1f3dd6448b52a4572c6022c810031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / ylemis-0.2.0-py3-none-any.whl
| Download URL | ylemis-0.2.0-py3-none-any.whl |
|---|---|
| Size | 18.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2e98331cc0bc566236edc378605b0eeac6112718dcd5981c3c2bc1e66102f8d3
|
|
BLAKE2b-256 checksum How to use checksums |
2256753fbee8556eb6fe8d5de420861b9fe111ed28ebe5af57e62e2f7f24bf50
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for ylemis 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.