Vaikora Python SDK
The official Python SDK for the Vaikora AI Agent Security Platform.
Installation
pip install vaikora
Quick Start
Simple Configuration
import vaikora
# Configure the SDK (do once at startup)
vaikora.configure(api_key="vk_your_api_key")
# Register your AI agent
agent = await vaikora.register(
name="my-ai-agent",
agent_type="autonomous",
capabilities=["database_write", "api_call"]
)
print(f"Agent registered: {agent.id}")
Using the Interceptor Decorator
The SDK provides a powerful decorator for securing AI agent actions:
import vaikora
vaikora.configure(api_key="vk_your_api_key")
# Register agent first
await vaikora.register(name="my-agent", agent_type="autonomous")
@vaikora.interceptor(
action_type="database.write",
resource="production",
require_approval=True,
validate_inputs=True,
)
async def write_to_database(data: dict) -> bool:
# Your code here - Vaikora validates and checks policies first
await database.insert(data)
return True
# Usage - automatically secured
result = await write_to_database({"user": "john", "action": "update"})
Data Validation
Validate data for PII, anomalies, and toxicity:
import vaikora
vaikora.configure(api_key="vk_your_api_key")
# Validate data before processing
result = await vaikora.validate_data(
data={"email": "user@example.com", "ssn": "123-45-6789"},
check_pii=True,
check_anomalies=True,
check_toxicity=True,
)
if result.pii_detected:
print(f"PII found: {[p.pii_type for p in result.pii_detections]}")
# Use cleaned data
clean_data = result.cleaned_data
Full Client Usage
For more control, use the client directly:
from vaikora import VaikoraClient
# Initialize the client
client = VaikoraClient(api_key="vk_your_api_key")
# Register an agent
agent = await client.agents.register(
name="my-ai-agent",
agent_type="autonomous",
capabilities=["database_write", "api_call", "file_access"]
)
# Submit an action for policy evaluation
result = await client.actions.submit(
agent_id=str(agent.id),
action_type="database_write",
resource="users_table",
payload={"user_id": 123, "data": {"name": "John"}}
)
if result.approved:
# Proceed with the action
pass
else:
print(f"Action blocked: {result.denial_reason}")
Synchronous Usage
For synchronous code, use the sync client:
from vaikora import VaikoraClientSync
client = VaikoraClientSync(api_key="your-api-key")
# All methods are synchronous
agent = client.agents.register(
name="my-sync-agent",
agent_type="autonomous"
)
Features
- Action Control: Submit actions for policy evaluation before execution
- Anomaly Detection: Automatic detection of unusual agent behavior
- Policy Enforcement: Server-side policy evaluation with local caching
- Alerting: Real-time alerts for security events
- Audit Logging: Immutable action logs with hash chains
Configuration
from vaikora import VaikoraClient
client = VaikoraClient(
api_key="your-api-key",
base_url="https://api.vaikora.com", # Default
timeout=30.0, # Request timeout in seconds
retry_count=3, # Number of retries for failed requests
agent_id="default-agent-id", # Default agent for actions
)
API Reference
Agents
# Register a new agent
agent = await client.agents.register(
name="my-agent",
agent_type="autonomous", # autonomous, semi_autonomous, or supervised
capabilities=["database_write", "api_call"],
metadata={"version": "1.0"}
)
# Get agent by ID
agent = await client.agents.get(agent_id)
# List all agents
agents = await client.agents.list(page=1, page_size=20)
# Update agent
agent = await client.agents.update(agent_id, name="new-name")
# Deactivate agent
await client.agents.deactivate(agent_id)
Actions
# Submit action for evaluation
result = await client.actions.submit(
agent_id="agent-uuid",
action_type="database_write",
resource="users_table",
payload={"query": "UPDATE users SET name='John' WHERE id=123"},
metadata={"source": "user_request"}
)
# Check result
if result.approved:
print(f"Action approved: {result.action_id}")
else:
print(f"Action denied: {result.denial_reason}")
# Get action details
action = await client.actions.get(action_id)
# List actions with filters
actions = await client.actions.list(
agent_id="agent-uuid",
action_type="database_write",
status="approved",
start_date=datetime(2024, 1, 1),
end_date=datetime.now()
)
Policies
# List policies
policies = await client.policies.list()
# Get policy details
policy = await client.policies.get(policy_id)
Alerts
# List alerts
alerts = await client.alerts.list(status="open", severity="high")
# Get alert details
alert = await client.alerts.get(alert_id)
# Acknowledge alert
await client.alerts.acknowledge(alert_id)
# Resolve alert
await client.alerts.resolve(alert_id, notes="Issue addressed")
Error Handling
from vaikora import VaikoraClient
from vaikora.exceptions import (
VaikoraError,
AuthenticationError,
RateLimitError,
PolicyViolationError,
NetworkError,
)
client = VaikoraClient(api_key="your-api-key")
try:
result = await client.actions.submit(...)
except AuthenticationError:
print("Invalid API key")
except RateLimitError as e:
print(f"Rate limited. Retry after {e.retry_after} seconds")
except PolicyViolationError as e:
print(f"Policy violation: {e.policy_name} - {e.message}")
except NetworkError:
print("Network error. Check your connection.")
except VaikoraError as e:
print(f"Vaikora error: {e}")
License
MIT License - see LICENSE for details.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
vaikora-0.2.0.tar.gz
(33.2 kB
view details)
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
vaikora-0.2.0-py3-none-any.whl
(38.9 kB
view details)
File details
Details for the file vaikora-0.2.0.tar.gz.
File metadata
- Download URL: vaikora-0.2.0.tar.gz
- Upload date:
- Size: 33.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
171ece5d156f5a012572f49ee93f1fb39f638e2daa7e6fd4158bfb0a9eb335e5
|
|
| MD5 |
c3e294e312d6760582841252e56b5348
|
|
| BLAKE2b-256 |
3ced6517c1a022055020e1d76e2585b557525b3520dedad24c458a91fec28e9b
|
File details
Details for the file vaikora-0.2.0-py3-none-any.whl.
File metadata
- Download URL: vaikora-0.2.0-py3-none-any.whl
- Upload date:
- Size: 38.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56f52c55cf4a296a12d02e46563114f8e8e5fe4bc8ec69d7c9200d35aa935327
|
|
| MD5 |
a1824d9fb3c974dea8c2d378d8c560ae
|
|
| BLAKE2b-256 |
d8e65d96bb6c49507c998adc8761720547db3b2ac9ea18fbf0dc509356dc42d9
|