Our SDK provides a simple, one-line solution to ensure your AI system outputs meet your safety requirements.
npm install @overseerai/sdk
import { Overseer } from '@overseerai/sdk'; // Initialize the clientconst overseer = new Overseer({ apiKey: 'your-api-key'}); // Validate contenttry { 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);}
npm install @overseerai/sdk-typescript
import { Overseer } from '@overseerai/sdk-typescript'; // Initialize the clientconst overseer = new Overseer({ apiKey: 'your-api-key'}); // Validate contentconst result = await overseer.validate('Hello! How can I help you today?'); if (result.valid) { console.log('Content is safe:', result.content);} else { console.log('Issues found:', result.issues);}
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); }}
import { Overseer } from '@overseerai/sdk-typescript';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: string): Promise<string> { // 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.valid) { return result.content; } else { throw new Error("Response failed safety checks: " + result.issues); }}
import { Overseer } from '@overseerai/sdk';import Anthropic from '@anthropic-ai/sdk'; const overseer = new Overseer({ apiKey: 'your-overseer-api-key'}); const anthropic = new Anthropic({ apiKey: 'your-anthropic-api-key'}); async function getAIResponse(prompt) { // Get response from Anthropic const message = await anthropic.messages.create({ model: "claude-2", messages: [{ role: "user", content: prompt }] }); // Validate the response const result = await overseer.validate(message.content); if (result.isAllowed) { return result.text; } else { throw new Error("Response failed safety checks: " + result.details?.reason); }}
import { Overseer } from '@overseerai/sdk-typescript';import Anthropic from '@anthropic-ai/sdk'; const overseer = new Overseer({ apiKey: 'your-overseer-api-key'}); const anthropic = new Anthropic({ apiKey: 'your-anthropic-api-key'}); async function getAIResponse(prompt: string): Promise<string> { // Get response from Anthropic const message = await anthropic.messages.create({ model: "claude-2", messages: [{ role: "user", content: prompt }] }); // Validate the response const result = await overseer.validate(message.content); if (result.valid) { return result.content; } else { throw new Error("Response failed safety checks: " + result.issues); }}