getting-started.mdRaw

Getting Started with AISentinel

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.

Prerequisites

Before diving in, ensure you have:

  • ✅ An AISentinel account (sign up at https://aisentinel.info/signup if you don't have one)
  • ✅ API key from your tenant dashboard (free tier available with rate limits)
  • ✅ Python 3.8+ or Node.js 16+ (for SDK examples)
  • ✅ Basic command-line knowledge

Installation and Setup

Install the AISentinel SDK for your preferred language. We'll cover Python, JavaScript, and Go.

Python

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__)"

JavaScript

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

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

Set Environment Variables

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.

Your First Governed API Call

Let's evaluate a simple input against AISentinel's default policies. This demonstrates core functionality: input validation, decision-making, and auditing.

Python Example

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

JavaScript Example

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

Go Example

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

Understanding the Results

  • Decision: ALLOW (input passed), DENY (blocked), or QUARANTINE (flagged for review).
  • Audit ID: Unique identifier for compliance tracking – view logs in your dashboard.
  • Metadata: Optional details like matched rules or risk scores.
DecisionExample InputWhy?
ALLOW"Hello, world!"Harmless content
DENY"My SSN is 123-45-6789"PII detected
QUARANTINE"How to hack a website?"Potentially harmful

Integrating into Automated Workflows

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.

Example with cURL

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": {}
}

Python Automation Example

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).

Experiment and Customize

Now that basics work, try these challenges:

  1. Sensitive Input: Change input to "User password: admin123". Expect DENY.
  2. Switch Rulepacks: Use rulepack="enterprise-pii-v3" for stricter checks.
  3. Add Metadata: Pass metadata={"user_id": "123"} for custom tracking.
  4. Output Evaluation: Evaluate AI-generated text instead of user input.

For more scenarios, check the demo folder in the repo.

Troubleshooting

  • "Invalid API key": Double-check environment variables or regenerate in the portal.
  • Rate limits: Free tier allows 100 requests/hour; upgrade for more.
  • Network errors: Ensure internet access; for offline, see Offline Mode.
  • SDK issues: Enable debug logs with export AISENTINEL_DEBUG=true.
  • Version mismatches: Check SDK compatibility and update using package managers.

Next Steps

  • Immediate: Explore the Dashboard for audit logs and rulepack management.
  • Intermediate: Integrate with frameworks like LangChain or CrewAI (see Examples).
  • Advanced: Set up BYOK Encryption or Team Management.
  • Community: Join forums, contribute to the Roadmap, or attend events.

For production deployments, review the Production Guide.