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_client-0.1.2.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

buddhi_client-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file buddhi_client-0.1.2.tar.gz.

File metadata

  • Download URL: buddhi_client-0.1.2.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for buddhi_client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 344373f04676d3d065ad59f92283b88761c09fcf97867a745719265bff79570b
MD5 61c1ba02e4b9d9ff9a594b2c93de4ebb
BLAKE2b-256 12b9b5b3c5c8bc333df1946a8d744167ad2c5e0d8ca22547f1326cc34bc574b4

See more details on using hashes here.

File details

Details for the file buddhi_client-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: buddhi_client-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.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_client-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2794f6781967960371511857727d642082005560bb42289fd42db289c2513f95
MD5 0520edcd2f23a70e8ad1f86b7c7e6879
BLAKE2b-256 eff961b5f81a0ae3934238c4debf39334cf25088b59e66f1bad85edd73720f83

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