Skip to main content

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

  1. Sign up at buddhiengine.com
  2. Create an API key in Dashboard → API Keys
  3. Create a guardrail policy in Dashboard → Guardrails (or use a template)
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buddhi_sdk-0.2.1.tar.gz (31.9 MB view details)

Uploaded Source

Built Distribution

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

buddhi_sdk-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file buddhi_sdk-0.2.1.tar.gz.

File metadata

  • Download URL: buddhi_sdk-0.2.1.tar.gz
  • Upload date:
  • Size: 31.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for buddhi_sdk-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a521b75cbe776c09eefd527ef2b9dd8288363e583712a7148691bb92ddd48df7
MD5 8f0efb03ec1225f38bd01335e2c9619b
BLAKE2b-256 c0bc378a0c167a8ca49b8800e9cf36a5f95ea2c59be4e1b82f8d35860dea1846

See more details on using hashes here.

File details

Details for the file buddhi_sdk-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: buddhi_sdk-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for buddhi_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ecbba69c4994d198939ec68a672910741b8c2baec0e71fe6b612604bac831a42
MD5 a3be9c08aaa6a11d8b401c811cbf84bc
BLAKE2b-256 d4efc2daffd095454c64aa9a4849d78c95c51b2eb9770e4201f83e0e19e64396

See more details on using hashes here.

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