Back to Documentation
v0.7.2

AI Assess Tech SDK

Official SDKs for assessing AI systems for ethical alignment. Test your AI across 4 dimensions: Lying, Cheating, Stealing, and Harm.

Privacy-First

Your AI's API keys, system prompts, and configuration never leave your environment

Server-Controlled

Test configuration, questions, and thresholds managed via Health Check Key

CI/CD Ready

Auto-detects GitHub Actions, GitLab CI, CircleCI, and more

#Installation

TypeScript / JavaScript

npm
npm install @aiassesstech/sdk
# or use the shorter package name:
npm install aiassesstech
yarn
yarn add @aiassesstech/sdk
# or
yarn add aiassesstech
pnpm
pnpm add @aiassesstech/sdk
# or
pnpm add aiassesstech
Two package names, same SDK: Both @aiassesstech/sdk and aiassesstech are identical. Use whichever you prefer!

Python

pip
pip install aiassess
poetry
poetry add aiassess
Python 3.8+: The Python SDK requires Python 3.8 or higher and uses Pydantic v2 for type safety.

#Quick Start

TypeScript

quickstart.ts
import { AIAssessClient } from '@aiassesstech/sdk';

// 1. Create client with your Health Check Key
const client = new AIAssessClient({
  healthCheckKey: process.env.AIASSESS_KEY!
});

// 2. Run assessment - configuration comes from server
const result = await client.assess(async (question) => {
  // Your AI callback - send question to your AI and return response
  return await myAI.chat(question);
});

// 3. Check result
console.log('Passed:', result.overallPassed);
console.log('Scores:', result.scores);
console.log('Classification:', result.classification);

Python

quickstart.py
import os
from aiassess import AIAssessClient

# 1. Create client with your Health Check Key
with AIAssessClient(health_check_key=os.environ["AIASSESS_KEY"]) as client:
    
    # 2. Define your AI callback
    def my_ai_callback(question: str) -> str:
        # Your AI logic here - return the response
        return my_ai.chat(question)
    
    # 3. Run assessment
    result = client.assess(my_ai_callback)
    
    # 4. Check result
    print(f"Passed: {result.overall_passed}")
    print(f"Scores: {result.scores}")
    print(f"Classification: {result.classification}")
Python Context Manager: Use with AIAssessClient(...) as client: for automatic resource cleanup, or instantiate directly with client = AIAssessClient(...).
Faster Assessments Coming Soon: Parallel processing (v0.9.2) will reduce assessment time from ~10 minutes to 30-60 seconds by distributing questions across multiple workers. Perfect for CI/CD pipelines and pre-flight checks.

#Supported AI Providers

The SDK works with any AI that accepts text input and returns text output. Here are the providers we've tested and documented:

๐ŸŸข

OpenAI

GPT-4, GPT-4o, GPT-3.5

๐ŸŸข

Anthropic

Claude 3, Claude 3.5

๐ŸŸข

Google

Gemini Pro, 1.5, 2.0

๐ŸŸข

xAI

Grok Beta, Grok 2

Custom Models Welcome: Self-hosted Llama, Mistral, fine-tuned models, or any API that returns text โ€” if it can answer questions, we can assess it.

#How It Works

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Your Environment                                            โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                             โ”‚
โ”‚  1. SDK fetches config from AI Assess Tech server           โ”‚
โ”‚     (questions, thresholds, test mode)                      โ”‚
โ”‚                                                             โ”‚
โ”‚  2. SDK sends questions to YOUR AI via your callback        โ”‚
โ”‚     โ†’ Your API keys stay private                            โ”‚
โ”‚     โ†’ Your system prompts stay private                      โ”‚
โ”‚                                                             โ”‚
โ”‚  3. SDK submits responses to server for scoring             โ”‚
โ”‚                                                             โ”‚
โ”‚  4. You receive scores, pass/fail, and classification       โ”‚
โ”‚                                                             โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
Privacy Guarantee: Your AI's API keys and system prompts never leave your environment. The SDK only sends the AI's responses to our servers for scoring.

#Security Architecture

The SDK is client-side code that runs in your environment. All security is enforced server-side โ€” the SDK cannot bypass rate limits, override thresholds, or fake scores.

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                   SECURITY ARCHITECTURE                          โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚                                                                  โ”‚
โ”‚  โœ… SERVER ENFORCES:                                             โ”‚
โ”‚  โ”œโ”€โ”€ Rate limiting (per IP for demo, per key for production)    โ”‚
โ”‚  โ”œโ”€โ”€ Thresholds (from database, not client-provided)            โ”‚
โ”‚  โ”œโ”€โ”€ Scoring (calculated server-side, immutable)                โ”‚
โ”‚  โ”œโ”€โ”€ API key validation (hashed, checked against database)      โ”‚
โ”‚  โ”œโ”€โ”€ Tier restrictions (DEMO, STANDARD, ENTERPRISE)             โ”‚
โ”‚  โ””โ”€โ”€ Result integrity (hashed and locked)                       โ”‚
โ”‚                                                                  โ”‚
โ”‚  ๐Ÿ”’ YOUR DATA STAYS PRIVATE:                                     โ”‚
โ”‚  โ”œโ”€โ”€ Your AI's API keys (OpenAI, Anthropic) never sent to us    โ”‚
โ”‚  โ”œโ”€โ”€ Your system prompts stay in your environment               โ”‚
โ”‚  โ””โ”€โ”€ Only AI responses are submitted for scoring                โ”‚
โ”‚                                                                  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

#What the Server Controls

Security ControlServer-Side Enforcement
Rate LimitingEnforced per IP (demo) or per key (production). SDK cannot bypass.
ThresholdsStored in your API key config. Client cannot override pass/fail thresholds.
ScoringCalculated entirely server-side based on question lookup.
QuestionsServed from database. Client cannot modify question content.
ResultsHashed with SHA-256 and locked. Tamper-proof verification.
Tier LimitsPer-tier limits enforced from API key record. See table below.

#Rate Limits by Tier

TierHourly LimitMonthly IncludedOverage
Demo5/hr per IPโ€”โ€”
Starter10/hr10$5/assessment
Professional50/hr50$3/assessment
Business200/hr200$2/assessment
Scale1000/hrUnlimitedโ€”
EnterpriseCustomCustomCustom

#Demo Tier (Open Source)

The open-source demo app uses a public demo key that is intentionally rate-limited server-side:

  • 5 assessments per hour per IP โ€” prevents abuse
  • Real questions and real scoring โ€” not mocked
  • Results marked as DEMO tier โ€” tracked separately
  • Upgrade prompts โ€” when limit is reached
For Production Use: Sign up at aiassesstech.com to get your own Health Check Key with higher limits and full features.

#Usage Examples

#With OpenAI

TypeScript

openai-example.ts
import OpenAI from 'openai';
import { AIAssessClient } from '@aiassesstech/sdk';

const openai = new OpenAI();
const client = new AIAssessClient({
  healthCheckKey: process.env.AIASSESS_KEY!
});

const result = await client.assess(async (question) => {
  const response = await openai.chat.completions.create({
    model: 'gpt-4',
    messages: [{ role: 'user', content: question }]
  });
  return response.choices[0].message.content || '';
});

console.log(`Classification: ${result.classification}`);
console.log(`Lying Score: ${result.scores.lying}/10`);
console.log(`Overall: ${result.overallPassed ? 'PASSED โœ…' : 'FAILED โŒ'}`);

Python

openai-example.py
import os
from openai import OpenAI
from aiassess import AIAssessClient

openai_client = OpenAI()

with AIAssessClient(health_check_key=os.environ["AIASSESS_KEY"]) as client:
    def openai_callback(question: str) -> str:
        response = openai_client.chat.completions.create(
            model="gpt-4",
            messages=[{"role": "user", "content": question}]
        )
        return response.choices[0].message.content or ""
    
    result = client.assess(openai_callback)
    
    print(f"Classification: {result.classification}")
    print(f"Lying Score: {result.scores.lying}/10")
    print(f"Overall: {'PASSED โœ…' if result.overall_passed else 'FAILED โŒ'}")

#With Anthropic (Claude)

TypeScript

anthropic-example.ts
import Anthropic from '@anthropic-ai/sdk';
import { AIAssessClient } from '@aiassesstech/sdk';

const anthropic = new Anthropic();
const client = new AIAssessClient({
  healthCheckKey: process.env.AIASSESS_KEY!
});

const result = await client.assess(async (question) => {
  const response = await anthropic.messages.create({
    model: 'claude-3-sonnet-20240229',
    max_tokens: 100,
    messages: [{ role: 'user', content: question }]
  });
  return response.content[0].type === 'text' 
    ? response.content[0].text 
    : '';
});

Python

anthropic-example.py
import os
from anthropic import Anthropic
from aiassess import AIAssessClient

anthropic = Anthropic()

with AIAssessClient(health_check_key=os.environ["AIASSESS_KEY"]) as client:
    def claude_callback(question: str) -> str:
        response = anthropic.messages.create(
            model="claude-3-sonnet-20240229",
            max_tokens=100,
            messages=[{"role": "user", "content": question}]
        )
        return response.content[0].text if response.content else ""
    
    result = client.assess(claude_callback)

#With Google Gemini

gemini-example.ts
import { GoogleGenerativeAI } from '@google/generative-ai';
import { AIAssessClient } from '@aiassesstech/sdk';

const genAI = new GoogleGenerativeAI(process.env.GEMINI_API_KEY!);
const model = genAI.getGenerativeModel({ model: 'gemini-pro' });

const client = new AIAssessClient({
  healthCheckKey: process.env.AIASSESS_KEY!
});

const result = await client.assess(async (question) => {
  const response = await model.generateContent(question);
  return response.response.text();
});

console.log(`Classification: ${result.classification}`);
console.log(`Overall: ${result.overallPassed ? 'PASSED โœ…' : 'FAILED โŒ'}`);
Gemini Models: Works with gemini-pro,gemini-1.5-pro, andgemini-2.0-flash.

#With xAI Grok

grok-example.ts
import { AIAssessClient } from '@aiassesstech/sdk';

const client = new AIAssessClient({
  healthCheckKey: process.env.AIASSESS_KEY!
});

const result = await client.assess(async (question) => {
  const response = await fetch('https://api.x.ai/v1/chat/completions', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.XAI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'grok-beta',
      messages: [{ role: 'user', content: question }]
    })
  });
  
  const data = await response.json();
  return data.choices[0].message.content;
});

console.log(`Classification: ${result.classification}`);
console.log(`Overall: ${result.overallPassed ? 'PASSED โœ…' : 'FAILED โŒ'}`);
Grok Models: Works with grok-beta andgrok-2. Requires an xAI API key fromx.ai.

#With Custom/Self-Hosted Models

Test any AI model with an HTTP API โ€” perfect for self-hosted, fine-tuned, or enterprise models:

custom-provider-example.ts
import { AIAssessClient } from '@aiassesstech/sdk';

const client = new AIAssessClient({
  healthCheckKey: process.env.AIASSESS_KEY!
});

const result = await client.assess(async (question) => {
  // Replace with your model's API endpoint
  const response = await fetch('https://your-model-server.com/v1/generate', {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.YOUR_MODEL_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      prompt: question,
      max_tokens: 100
    })
  });
  
  const data = await response.json();
  return data.text || data.response || data.output;
});
Works with any model: Llama, Mistral, fine-tuned GPT, custom models โ€” as long as it accepts a prompt and returns text, the SDK can test it.

#With Progress Updates

progress-example.ts
const result = await client.assess(
  async (question) => await myAI.chat(question),
  {
    onProgress: (progress) => {
      console.log(`${progress.percentage}% - Testing ${progress.dimension}`);
      // Output: "25% - Testing lying"
      // Output: "50% - Testing cheating"
      // Output: "75% - Testing stealing"
      // Output: "100% - Testing harm"
    }
  }
);

#Startup Health Check (Blocking)

blocking-example.ts
// Block until AI passes - exits process on failure
await client.blockUntilPass(
  async (question) => await myAI.chat(question),
  {
    maxRetries: 3,
    retryDelayMs: 60000, // 1 minute between retries
    exitOnFailure: true
  }
);

console.log('โœ… AI passed ethical assessment, starting app...');
startApp();

#With Retry Wrapper (for Flaky APIs)

retry-example.ts
import { AIAssessClient, withRetry } from '@aiassesstech/sdk';

const result = await client.assess(
  withRetry(
    async (question) => await flakyAI.chat(question),
    { maxRetries: 3, backoffMs: 1000 }
  )
);

#Dry Run Mode (Development)

dryrun-example.ts
// Only asks 5 questions, returns mock scores
const result = await client.assess(
  async (question) => await myAI.chat(question),
  { dryRun: true }
);

#Assessment Result

The assess() method returns an AssessmentResult object:

AssessmentResult type
interface AssessmentResult {
  runId: string;           // Server-generated ID for verification
  sdkSessionId: string;    // Client-generated session ID
  
  scores: {
    lying: number;         // 0-10 scale
    cheating: number;
    stealing: number;
    harm: number;
  };
  
  passed: {
    lying: boolean;        // Did score meet threshold?
    cheating: boolean;
    stealing: boolean;
    harm: boolean;
  };
  
  overallPassed: boolean;  // All dimensions must pass
  
  classification: 
    | "Well Adjusted"      // High scores across all dimensions
    | "Misguided"          // Low lying, high harm (believes false things but tries to do good)
    | "Manipulative"       // High lying, low harm (deceives but avoids direct harm)
    | "Psychopath";        // Low scores across the board
  
  thresholds: {            // Thresholds used from server config
    lying: number;
    cheating: number;
    stealing: number;
    harm: number;
  };
  
  verifyUrl: string;       // URL to verify this result
  completedAt: string;     // ISO timestamp
  
  versions: {
    sdk: string;           // SDK version used
    questionSet: string;   // Question set version
  };
  
  keyName: string;         // Name of Health Check Key used
  
  // Ethereum-verified question bank (v1.2.12+)
  bankVerification: {
    bankVersionId: string;    // Question bank version ID
    bankHash: string | null;  // SHA256 hash of questions
    version: string;          // Semantic version (e.g., "1.0.0")
    lockedAt: string | null;  // ISO timestamp when locked
    ethereumTxHash: string | null;  // ETH tx hash (on-chain proof)
    etherscanUrl: string | null;    // Direct Etherscan link
  };
}

#Result Verification

Every assessment generates a tamper-proof verification URL that can be shared with auditors, compliance teams, or stakeholders to independently verify the assessment.

verification-example.ts
const result = await client.assess(callback);

// Get the verification URL
console.log(`Verify at: ${result.verifyUrl}`);
// https://aiassesstech.com/verify/result/clx123abc...

// The verification page shows:
// โœ“ Assessment date and time
// โœ“ Scores for all 4 dimensions
// โœ“ Pass/fail status
// โœ“ Classification result
// โœ“ Cryptographic hash proof
Immutable Results: Assessment results are cryptographically hashed using SHA-256 and locked immediately after calculation. Results cannot be modified after completion โ€” any tampering would invalidate the verification hash.

#Embedding Verification Badges

Display your AI's certification status on your website (coming in v1.0):

badge-example.html
<!-- AI Assess Tech Certification Badge -->
<a href="https://www.aiassesstech.com/verify/YOUR_RUN_ID">
  <img 
    src="https://www.aiassesstech.com/badge/YOUR_RUN_ID" 
    alt="AI Assess Tech Certified"
  />
</a>

#Ethereum Verification

All assessments use an Ethereum-verified question bank. The question bank is cryptographically locked and published to the Ethereum blockchain, providing:

Immutability

Questions cannot be modified after locking โ€” cryptographic proof of integrity

Auditability

On-chain proof that all assessments use the same verified questions

Transparency

Anyone can verify the question bank hash on Ethereum

#Accessing ETH Verification Data

Every assessment result includes bank verification info:

eth-verification.ts
const result = await client.assess(callback);

// Display ETH verification to users
console.log(`Bank Version: ${result.bankVerification.version}`);
console.log(`Locked At: ${result.bankVerification.lockedAt}`);
console.log(`Bank Hash: ${result.bankVerification.bankHash}`);

// Link to Etherscan for on-chain proof
if (result.bankVerification.etherscanUrl) {
  console.log(`Verify on Ethereum: ${result.bankVerification.etherscanUrl}`);
  // Opens: https://etherscan.io/tx/0xea1c7c85fb5902b0db213f444c4a30...
}

#HTTP Headers

SDK responses include verification headers for programmatic access:

HeaderDescription
X-Bank-VersionQuestion bank version (e.g., 1.0.0)
X-Bank-HashSHA256 hash of the question bank
X-ETH-TxHashEthereum transaction hash for verification
Enterprise Compliance: ETH verification provides auditable proof for SOC 2, ISO 27001, and other compliance frameworks that require immutable audit trails.

#Configuration

#Client Options

configuration.ts
const client = new AIAssessClient({
  // Required: Your Health Check Key from the dashboard
  healthCheckKey: 'hck_...',
  
  // Optional: Override base URL (default: https://www.aiassesstech.com)
  baseUrl: 'https://www.aiassesstech.com',
  
  // Optional: Per-question timeout in ms (default: 30000 = 30s)
  perQuestionTimeoutMs: 30000,
  
  // Optional: Overall timeout in ms (default: 360000 = 6 min)
  overallTimeoutMs: 360000
});

#Server-Controlled Configuration

Configuration is managed via the Health Check Key on the AI Assess Tech dashboard:

  • Test Mode: ISOLATED (each question independent) or CONVERSATIONAL (beta in v0.9.5)
  • Framework: Which question set to use
  • Thresholds: Pass thresholds per dimension (0-10 scale)
  • Rate Limits: Hourly/monthly assessment limits
Pro tip: Create different keys for different scenarios:
  • โ€ข prod-strict - Production with strict thresholds
  • โ€ข staging-relaxed - Staging with relaxed thresholds
  • โ€ข ci-quick - CI/CD pipeline checks

#Error Handling

error-handling.ts
import { 
  AIAssessClient, 
  SDKError, 
  ValidationError, 
  RateLimitError,
  QuestionTimeoutError,
  ErrorCode 
} from '@aiassesstech/sdk';

try {
  const result = await client.assess(callback);
} catch (error) {
  if (error instanceof RateLimitError) {
    console.log(`Rate limited. Retry after ${error.retryAfterMs}ms`);
  } else if (error instanceof ValidationError) {
    if (error.code === ErrorCode.KEY_EXPIRED) {
      console.log('Health Check Key has expired');
    } else if (error.code === ErrorCode.INVALID_KEY) {
      console.log('Invalid Health Check Key');
    }
  } else if (error instanceof QuestionTimeoutError) {
    console.log(`Question ${error.questionId} timed out`);
  } else if (error instanceof SDKError) {
    console.log(`SDK Error: ${error.message} (${error.code})`);
  }
}

Error Codes

CodeDescription
INVALID_KEYHealth Check Key is invalid or not found
KEY_EXPIREDHealth Check Key has expired
RATE_LIMITEDToo many requests, try again later
QUESTION_TIMEOUTAI took too long to respond to a question
NETWORK_ERRORNetwork connection failed
SERVER_ERRORServer-side error occurred

#CI/CD Integration

#GitHub Actions

.github/workflows/ai-health-check.yml
name: AI Ethics Health Check

on:
  push:
    branches: [main]
  schedule:
    - cron: "0 */6 * * *" # Every 6 hours

jobs:
  health-check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "20"

      - name: Install dependencies
        run: npm install @aiassesstech/sdk openai

      - name: Run AI Health Check
        env:
          AIASSESS_KEY: ${{ secrets.AIASSESS_KEY }}
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
        run: |
          node -e "
            const { AIAssessClient } = require('@aiassesstech/sdk');
            const OpenAI = require('openai');
            
            const openai = new OpenAI();
            const client = new AIAssessClient({ 
              healthCheckKey: process.env.AIASSESS_KEY 
            });
            
            client.assess(async (q) => {
              const r = await openai.chat.completions.create({
                model: 'gpt-4',
                messages: [{ role: 'user', content: q }]
              });
              return r.choices[0].message.content;
            }).then(result => {
              console.log('Classification:', result.classification);
              console.log('Scores:', JSON.stringify(result.scores));
              process.exit(result.overallPassed ? 0 : 1);
            }).catch(err => {
              console.error('Error:', err.message);
              process.exit(2);
            });
          "

#With Metadata for Traceability

cicd-with-metadata.ts
const result = await client.assess(
  async (question) => await myAI.chat(question),
  {
    metadata: {
      gitCommit: process.env.GITHUB_SHA,
      branch: process.env.GITHUB_REF_NAME,
      deployVersion: process.env.VERSION,
      environment: process.env.NODE_ENV
    }
  }
);

// Exit code for CI/CD
// 0 = passed, 1 = failed, 2 = error
process.exit(result.overallPassed ? 0 : 1);

#Environment Detection

The SDK automatically detects CI/CD environments:

environment-detection.ts
import { detectEnvironment, isCI } from '@aiassesstech/sdk';

console.log('Is CI:', isCI());
console.log('Environment:', detectEnvironment());
// {
//   nodeVersion: 'v20.10.0',
//   platform: 'linux',
//   ciProvider: 'github-actions',
//   ciJobId: '12345678',
//   gitCommit: 'abc123...',
//   gitBranch: 'main'
// }

Supported CI Providers

  • GitHub Actions
  • GitLab CI
  • CircleCI
  • Jenkins
  • Travis CI
  • Buildkite
  • Azure Pipelines
  • AWS CodeBuild
  • Bitbucket Pipelines
  • Drone CI
  • Vercel
  • Netlify

#Utilities

#withRetry

Wrap your AI callback with automatic retry logic:

with-retry.ts
import { withRetry } from '@aiassesstech/sdk';

const resilientCallback = withRetry(
  async (question) => await flakyAPI.chat(question),
  {
    maxRetries: 3,      // Number of retry attempts
    backoffMs: 1000,    // Initial backoff delay
    backoffMultiplier: 2 // Exponential backoff multiplier
  }
);

const result = await client.assess(resilientCallback);

#Webhook Notifications

Coming in v0.9.0: Webhook notifications are planned for Q1 2026.Contact us to be notified when available.

Configure webhooks to receive real-time notifications when assessments complete:

webhook-payload-preview.json
{
  "event": "assessment.completed",
  "runId": "clx123abc...",
  "timestamp": "2026-02-15T10:30:00Z",
  "result": {
    "overallPassed": true,
    "classification": "Well Adjusted",
    "scores": {
      "lying": 8.5,
      "cheating": 9.0,
      "stealing": 8.7,
      "harm": 9.2
    }
  },
  "metadata": {
    "keyName": "prod-strict",
    "environment": "production"
  }
}

Planned Webhook Events

  • assessment.completed โ€” Assessment finished (pass or fail)
  • assessment.failed โ€” Assessment failed thresholds
  • assessment.warning โ€” Score within 1 point of threshold
  • key.rate_limited โ€” Health Check Key hit rate limit

#Requirements

TypeScript SDK

Python SDK

  • Python 3.8 or higher
  • Pydantic v2 (installed automatically)
  • Valid Health Check Key from AI Assess Tech

#Python SDK

The Python SDK provides the same functionality as the TypeScript SDK, with Python-native features like context managers, async support, Pydantic models, and a CLI tool.

#Async Client

For async applications, use AsyncAIAssessClient:

async-example.py
import asyncio
import os
from aiassess import AsyncAIAssessClient

async def main():
    async with AsyncAIAssessClient(
        health_check_key=os.environ["AIASSESS_KEY"]
    ) as client:
        
        async def my_async_callback(question: str) -> str:
            # Your async AI logic here
            return await my_async_ai.chat(question)
        
        result = await client.assess(my_async_callback)
        print(f"Passed: {result.overall_passed}")

asyncio.run(main())

#CLI Tool

The Python SDK includes a command-line interface for quick assessments:

CLI Usage
# Run assessment with OpenAI
aiassess run --provider openai --model gpt-4

# Run with Anthropic
aiassess run --provider anthropic --model claude-3-sonnet-20240229

# Dry run mode (fewer questions, mock scores)
aiassess run --provider openai --model gpt-4 --dry-run

# Check SDK version
aiassess --version
Environment Variables: Set AIASSESS_KEY and your AI provider's API key (e.g., OPENAI_API_KEY) before running CLI commands.

#Progress Tracking

progress-example.py
from aiassess import AIAssessClient

with AIAssessClient(health_check_key=key) as client:
    def on_progress(progress):
        print(f"{progress.percentage}% - Testing {progress.dimension}")
    
    result = client.assess(
        callback=my_callback,
        on_progress=on_progress
    )

#Startup Health Check (Blocking)

blocking-example.py
from aiassess import AIAssessClient

with AIAssessClient(health_check_key=key) as client:
    # Block until AI passes - raises exception on failure
    client.block_until_pass(
        callback=my_callback,
        max_retries=3,
        retry_delay_seconds=60
    )
    
    print("โœ… AI passed ethical assessment, starting app...")
    start_app()

#Python Error Handling

error-handling.py
from aiassess import (
    AIAssessClient,
    AIAssessError,
    RateLimitError,
    ValidationError,
    QuestionTimeoutError,
)

try:
    with AIAssessClient(health_check_key=key) as client:
        result = client.assess(my_callback)
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after_seconds}s")
except ValidationError as e:
    if e.code == "KEY_EXPIRED":
        print("Health Check Key has expired")
    elif e.code == "INVALID_KEY":
        print("Invalid Health Check Key")
except QuestionTimeoutError as e:
    print(f"Question {e.question_id} timed out")
except AIAssessError as e:
    print(f"SDK Error: {e.message} ({e.code})")

#Type Safety with Pydantic

All response models use Pydantic v2 for full type safety and IDE autocompletion:

types.py
from aiassess.models import AssessmentResult, Scores

result: AssessmentResult = client.assess(my_callback)

# Full IDE autocompletion and type checking
scores: Scores = result.scores
print(f"Lying: {scores.lying}")      # float
print(f"Cheating: {scores.cheating}")  # float
print(f"Overall: {result.overall_passed}")  # bool
print(f"Classification: {result.classification}")  # Literal type
Full Feature Parity: The Python SDK supports all features of the TypeScript SDK including progress tracking, dry run mode, blocking mode, and Ethereum verification.

#Getting a Health Check Key

  1. Sign up at https://www.aiassesstech.com
  2. Go to Settings โ†’ Health Check Keys
  3. Click "Create New Key"
  4. Configure your key (test mode, thresholds, rate limits)
  5. Copy the key (hck_...) and store it securely
Security: Your Health Check Key is only shown once when created. Store it securely in environment variables, never commit it to version control.

#Support

Documentation

View Docs

TypeScript SDK

GitHub Issues

Python SDK

GitHub Issues

Email Support

Contact Us

MIT ยฉ AI Assess Tech

Back to Documentation ยท Pricing ยท Contact