AISentinel SDK Documentation

All AISentinel SDKs have been extracted to their own repositories for independent development and releases:

Official SDKs

Python SDK

JavaScript/TypeScript SDK

Go SDK

  • Repository: mfifth/aisentinel-go-sdk
  • Package: Available via go get github.com/mfifth/aisentinel-go-sdk
  • Features: Idiomatic Go client with context support, structured logging, and high performance
  • Installation: go get github.com/mfifth/aisentinel-go-sdk

Each SDK repository contains comprehensive documentation including:

README.md          # Installation and quick start guide
docs/              # Comprehensive documentation
examples/          # Integration examples
tests/             # Test suite
CHANGELOG.md       # Version history and migration notes
CONTRIBUTING.md    # Development guidelines

Looking for additional language support? Consult the SDK generator docs and open a feature request with the generated baseline.

Quick code examples

Below are minimal examples showing how to evaluate a decision or run an audit with each SDK. These are intended as small, copy-pasteable samples — consult the SDK repo for full documentation and feature details.

Python SDK (idiomatic example)

Install: pip install aisentinel-sdk

from aisentinel import AISentinelClient

client = AISentinelClient(api_key="YOUR_TENANT_API_KEY")

# Evaluate a decision against a rulepack
response = client.evaluate(rulepack_id="default", input={"text": "Customer SSN: 111-22-3333"})
print("Allowed:", response.allowed)
print("Reasons:", response.reasons)

JavaScript / TypeScript SDK (browser / Node)

Install: npm install @mfifth/aisentinel-javascript-sdk

import AISentinel from '@mfifth/aisentinel-javascript-sdk';

const client = new AISentinel({ apiKey: process.env.AISENTINEL_KEY });

async function run() {
	const res = await client.evaluate({ rulepackId: 'default', input: { text: 'Sensitive data 4111-1111-1111-1111' } });
	console.log('Allowed:', res.allowed);
	console.log('Reasons:', res.reasons);
}
run();

Go SDK (exact example from aisentinel-go-sdk/examples/basic)

Install: go get github.com/mfifth/aisentinel-go-sdk

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"time"

	governor "github.com/mfifth/aisentinel-go-sdk"
)

func main() {
	cfg := governor.Config{APIKey: "test-key", OfflineMode: true}
	ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
	defer cancel()

	gov, err := governor.NewGovernor(ctx, cfg)
	if err != nil {
		panic(err)
	}
	defer gov.Close()

	payload, _ := json.Marshal(map[string]string{"rule-1": "example"})
	result, err := gov.Evaluate(ctx, governor.DecisionRequest{RulepackID: "local", Payload: payload})
	if err != nil {
		fmt.Println("error:", err)
		return
	}
	fmt.Println("allowed:", result.Allowed, "reason:", result.Reason)
}