Skip to content

Installation & Usage

Our SDK provides a simple, one-line solution to ensure your AI system outputs meet your safety requirements.

Terminal window
npm install @overseerai/sdk
import { Overseer } from '@overseerai/sdk';
// Initialize the client
const overseer = new Overseer({
apiKey: 'your-api-key'
});
// Validate content
try {
const result = await overseer.validate('Hello! How can I help you today?');
if (result.isAllowed) {
console.log('Content is safe:', result.text);
} else {
console.log('Content was rejected:', result.text);
console.log('Reason:', result.details?.reason);
}
} catch (error) {
console.error('Error validating content:', error);
}

Integration Examples

import { Overseer } from '@overseerai/sdk';
import OpenAI from 'openai';
const overseer = new Overseer({
apiKey: 'your-overseer-api-key'
});
const openai = new OpenAI({
apiKey: 'your-openai-api-key'
});
async function getAIResponse(prompt) {
// Get response from OpenAI
const completion = await openai.chat.completions.create({
model: "gpt-4",
messages: [{ role: "user", content: prompt }]
});
// Validate the response
const result = await overseer.validate(completion.choices[0].message.content);
if (result.isAllowed) {
return result.text;
} else {
throw new Error("Response failed safety checks: " + result.details?.reason);
}
}