Python SDK for Buddhi Engine — AI Guardrail Validation
Project description
buddhi-client
Python SDK for the Buddhi Engine — AI Guardrail Validation
Validate AI inputs and outputs against safety policies in 3 lines of code. Built for the Buddhi Engine guardrail platform (Raksha M).
Installation
pip install buddhi-client
Requires Python 3.8+.
Quick Start
from buddhi import RakshaClient
client = RakshaClient(api_key="be_YOUR_KEY")
result = client.validate("Can you share patient lab results?")
print(result.decision) # "APPROVE" or "BLOCK"
print(result.is_blocked) # True / False
Setup
- Sign up at buddhiengine.com
- Create an API key in Dashboard → API Keys
- Create a guardrail policy in Dashboard → Guardrails (or use a template)
- Install:
pip install buddhi-client
Usage
Basic Validation
from buddhi import RakshaClient
client = RakshaClient(api_key="be_abc123...")
# Check a user message
result = client.validate("What's the weather like?")
print(result.decision) # APPROVE, BLOCK, REJECT, CONTINUE, WARN
print(result.is_allowed) # True
print(result.is_blocked) # False
Validate Against a Specific Policy
result = client.validate(
"Delete all user data",
policy_id="data-protection-policy-a1b2c3d4",
)
print(result.reason)
print(result.rule_triggered)
print(result.severity)
Use in a Chatbot / AI Pipeline
def chatbot(user_message: str) -> str:
check = client.validate(user_message)
if check.is_blocked:
return f"I can't help with that. ({check.reason})"
# Safe — call your AI model
return my_llm.generate(user_message)
Rich Context (Dict Input)
Pass structured context when your policy rules need extra fields:
result = client.validate({
"user_message": "Book a meeting at 3am",
"user_role": "intern",
"department": "finance",
})
Batch Evaluation (Professional+)
results = client.validate_batch([
{"input_context": "message 1"},
{"input_context": "message 2", "policy_id": "my-policy"},
])
for r in results.results:
print(r.decision)
Check Usage
usage = client.get_usage()
print(f"{usage.monthly_usage}/{usage.monthly_limit} calls used")
print(f"{usage.remaining} remaining")
List Policies
for policy in client.list_policies():
print(f"{policy.name} (rules={policy.rule_count})")
Async Client
import asyncio
from buddhi import AsyncRakshaClient
async def main():
async with AsyncRakshaClient(api_key="be_abc123...") as client:
result = await client.validate("Check this message")
print(result.decision)
asyncio.run(main())
Self-Hosted / Custom Base URL
client = RakshaClient(
api_key="be_abc123...",
base_url="https://guardrails.yourcompany.internal/api/v1",
)
Specific Instance
client = RakshaClient(
api_key="be_abc123...",
instance_id="aerm_005_prod",
)
Response Object
result = client.validate("some text")
result.decision # str: APPROVE, BLOCK, REJECT, CONTINUE, WARN
result.reason # str or None
result.severity # str or None
result.rule_triggered # str or None
result.policy_id # str or None
result.evaluated_rules # int
result.execution_time_ms # float
result.trace # dict or None (if include_trace=True)
result.usage # dict: {monthly_limit, monthly_usage, remaining}
result.is_allowed # True if APPROVE or CONTINUE
result.is_blocked # True if BLOCK, BLOCKED, or REJECT
Error Handling
from buddhi import (
RakshaClient,
AuthenticationError,
QuotaExceededError,
PolicyNotFoundError,
InstanceUnavailableError,
)
client = RakshaClient(api_key="be_abc123...")
try:
result = client.validate("test")
except AuthenticationError:
print("Bad API key")
except QuotaExceededError:
print("Monthly limit reached — upgrade your plan")
except PolicyNotFoundError:
print("Policy doesn't exist")
except InstanceUnavailableError:
print("No running AERM instance — start one in the dashboard")
Pricing Tiers
| Plan | Monthly Calls | Overage | Batch |
|---|---|---|---|
| Starter/Free | 500 | Blocked (429) | No |
| Professional | 10,000 | $0.012/call | Yes |
| Business | 100,000 | $0.006/call | Yes |
| Enterprise | Unlimited | Negotiated | Yes |
Requirements
License
MIT
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 buddhi_client-0.1.3.tar.gz.
File metadata
- Download URL: buddhi_client-0.1.3.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
200300f30b5a1972d42a4d62ba2f721fd9c070f834cf68b785919ff023229f78
|
|
| MD5 |
11d5c6d8bfc4885145e9bb429cff506e
|
|
| BLAKE2b-256 |
e36e2089a0bdbcbe68a5bf9789316730df00dcafb15e51dc4908b90253511b43
|
File details
Details for the file buddhi_client-0.1.3-py3-none-any.whl.
File metadata
- Download URL: buddhi_client-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7b9a3166d5ac921321231c02b1feb8641ac7af50cc6fcfe2c5804595638228d8
|
|
| MD5 |
f2683bac611bf60b2cc6c7eeee9a3c23
|
|
| BLAKE2b-256 |
8c40a79faa6b6842678ef67488c99e41c8d450ce557b31577d5ba3c9805411a0
|