Secure your AI applications in minutes with AISentinel – the governance platform for responsible AI. This guide walks you through installing the SDK, making your first policy evaluation, and exploring key features to ensure safe, compliant AI interactions.
Before diving in, ensure you have:
Install the AISentinel SDK for your preferred language. We'll cover Python, JavaScript, and Go.
pip install aisentinel # Installs the latest stable version
# Or specify a minimum version: pip install "aisentinel>=1.0.0"
Verify: python -c "import aisentinel; print(aisentinel.__version__)"
npm install aisentinel # Installs the latest stable version
# Or specify a version range: npm install "aisentinel@^1.0.0"
Verify: node -e "console.log(require('aisentinel').version)"
go get github.com/aisentinel/go-sdk@latest # Gets the latest version
# Or specify a version: go get github.com/aisentinel/go-sdk@v1.0.0
Verify: go list -m github.com/aisentinel/go-sdk
Get your tenant ID and API key from the portal, then set them:
export AISENTINEL_TENANT_ID="your-tenant-id"
export AISENTINEL_API_KEY="your-api-key"
For production, use secure methods like .env files or key vaults.
Let's evaluate a simple input against AISentinel's default policies. This demonstrates core functionality: input validation, decision-making, and auditing.
Create first_eval.py:
import os
from aisentinel import Client
# Initialize client
client = Client(
api_key=os.environ["AISENTINEL_API_KEY"],
tenant_id=os.environ["AISENTINEL_TENANT_ID"]
)
# Evaluate input
decision = client.policies.evaluate(
input="Hello, world!",
rulepack="default"
)
# Output results
print(f"Decision: {decision.decision}") # e.g., ALLOW
print(f"Audit ID: {decision.audit_id}") # Unique tracking ID
print(f"Metadata: {decision.metadata}") # Additional details
Run: python first_eval.py
Create first_eval.js:
import { AISentinelClient } from "aisentinel";
const client = new AISentinelClient({
apiKey: process.env.AISENTINEL_API_KEY,
tenantId: process.env.AISENTINEL_TENANT_ID,
});
async function main() {
const decision = await client.policies.evaluate({
input: "Hello, world!",
rulepack: "default",
});
console.log(`Decision: ${decision.decision}`);
console.log(`Audit ID: ${decision.auditId}`);
console.log(`Metadata: ${decision.metadata}`);
}
main();
Run: node first_eval.js
Create first_eval.go:
package main
import (
"fmt"
"os"
"github.com/aisentinel/go-sdk/client"
)
func main() {
c := client.New(client.Config{
APIKey: os.Getenv("AISENTINEL_API_KEY"),
TenantID: os.Getenv("AISENTINEL_TENANT_ID"),
})
decision, err := c.Policies.Evaluate("Hello, world!", "default")
if err != nil {
panic(err)
}
fmt.Printf("Decision: %s\n", decision.Decision)
fmt.Printf("Audit ID: %s\n", decision.AuditID)
fmt.Printf("Metadata: %v\n", decision.Metadata)
}
Run: go run first_eval.go
| Decision | Example Input | Why? |
|---|---|---|
| ALLOW | "Hello, world!" | Harmless content |
| DENY | "My SSN is 123-45-6789" | PII detected |
| QUARANTINE | "How to hack a website?" | Potentially harmful |
AISentinel can be seamlessly integrated into any automated workflow via the /preflight endpoint. Simply send a POST request with your API token and the candidate payload for evaluation.
curl -X POST https://api.aisentinel.info/preflight \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Tenant-ID: YOUR_TENANT_ID" \
-H "Content-Type: application/json" \
-d '{
"candidate": {
"type": "tool_call",
"tool": "send_email",
"args": {
"to": "user@example.com",
"subject": "Meeting Reminder",
"body": "Don'\''t forget our meeting at 3 PM."
},
"estimate": {
"cost": 0.02,
"risk": 0.05,
"steps_left": 0
},
"evidence_expect": []
},
"rulepacks": [
"default"
]
}'
Response:
{
"decision": "ALLOW",
"audit_id": "abc-123-def",
"metadata": {}
}
import requests
import os
response = requests.post(
"https://api.aisentinel.info/preflight",
headers={
"Authorization": f"Bearer {os.environ['AISENTINEL_API_KEY']}",
"X-Tenant-ID": os.environ["AISENTINEL_TENANT_ID"],
"Content-Type": "application/json"
},
json={
"candidate": {
"type": "tool_call",
"tool": "create_support_ticket",
"args": {
"title": "Login Issue",
"description": "User unable to log in after password reset.",
"priority": "high"
},
"estimate": {
"cost": 0.03,
"risk": 0.1,
"steps_left": 2
},
"evidence_expect": ["ticket_id"]
},
"rulepacks": ["default"]
}
)
print(response.json())
This allows CI/CD pipelines, chatbots, or any system to pre-check content before processing.
Candidate Payload Fields (all optional except type, tool, args):
estimate: Metadata about expected execution details (e.g., cost in dollars, risk as a score from 0-1, steps_left remaining in the workflow).evidence_expect: List of expected outputs or evidence from the tool (e.g., ["ticket_id"] for a support ticket creation).Now that basics work, try these challenges:
"User password: admin123". Expect DENY.rulepack="enterprise-pii-v3" for stricter checks.metadata={"user_id": "123"} for custom tracking.For more scenarios, check the demo folder in the repo.
export AISENTINEL_DEBUG=true.For production deployments, review the Production Guide.