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.1.tar.gz (14.8 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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: buddhi_client-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 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.1.tar.gz
Algorithm Hash digest
SHA256 1b72e59eec3002d0e3b9b9260f38829c7f8f11be4fc9551765355e643f0404ce
MD5 474b18f21361a304b9209b8e3cc505aa
BLAKE2b-256 ea3b3b7f75232bba694b7e6abcede73a2a20592727c682bd5094a4919ffd8f03

See more details on using hashes here.

File details

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

File metadata

  • Download URL: buddhi_client-0.1.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 355edd9bf95eafa9c99aa5c273c795848b7a357158fa14ec2f5d2834f6cddedc
MD5 0f478ebd78aa7a2fb4592ae79a6ce6b1
BLAKE2b-256 ad2efb29d82c7d4ae77c3b2d93d4d2e45f3b756d199376ef2822930a4a872f3a

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