@guardaian/sdk
v1.0.1
Published
Zero-friction AI governance and monitoring SDK for Node.js applications
Maintainers
Readme
GuardAIan SDK
Monitor ALL your AI usage with one line of code
The only SDK that automatically tracks OpenAI, Anthropic, Google, Azure, AWS, Cohere & Hugging Face
🚀 Get Started Free • 📚 Documentation • 💬 Support
✨ One import. Zero code changes. Complete AI governance.
🚀 Quick Start (30 seconds)
npm install @guardaian/sdkimport '@guardaian/sdk/auto';
import { GuardAIan } from '@guardaian/sdk';
GuardAIan.init({ apiKey: 'gai_your_key' }); // Get free key at app.guardaianlabs.com
// Your existing AI code now tracked automatically! 🛡️
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }]
});
// ✅ Cost, tokens, compliance automatically tracked in dashboard✅ Zero code changes • ✅ All AI providers • ✅ Free dashboard
🚀 Get Free API Key • 📚 Full Documentation
🚀 Production-Ready AI Governance
Enterprise-grade reliability • Developer-friendly integration • Comprehensive monitoring
Built for companies that need complete AI governance without compromising developer velocity.
From startups to enterprise, GuardAIan scales with your AI usage.
✅ Zero-downtime deployment
✅ Enterprise security standards
✅ Comprehensive provider coverage
✅ Real-time monitoring & alerts
💡 Why GuardAIan SDK?
🎯 Universal Coverage
- 7 AI providers supported - OpenAI, Anthropic, Google, Azure, AWS, Cohere, Hugging Face
- 85% market coverage - Works with all major enterprise AI services
- One SDK for everything - No more juggling multiple monitoring tools
⚡ Zero Friction
- One import line -
import '@guardaian/sdk/auto' - No code changes - Works with your existing AI implementations
- Drop-in replacement - Transparent interception, identical APIs
🛡️ Enterprise Ready
- Real-time compliance - Instant policy enforcement
- Complete audit trails - Full regulatory compliance (SOC2, GDPR)
- Professional dashboards - Executive-ready reporting
💰 Immediate ROI
- Cost optimization - Track spending across all AI services
- Usage insights - Optimize AI usage patterns
- Policy enforcement - Prevent budget overruns automatically
🤖 Supported AI Providers
| Provider | Models | Package | Status |
|----------|--------|---------|--------|
| 🤖 OpenAI | GPT-4, GPT-3.5, DALL-E | openai | ✅ Full Support |
| 🧠 Anthropic | Claude 3.5 Sonnet, Opus | @anthropic-ai/sdk | ✅ Full Support |
| 🔍 Google | Gemini Pro, Flash | @google/generative-ai | ✅ Full Support |
| ☁️ Azure OpenAI | Enterprise GPT models | openai + Azure | ✅ Full Support |
| 🔶 AWS Bedrock | Claude, Llama, Titan | @aws-sdk/client-bedrock-runtime | ✅ Full Support |
| 🟦 Cohere | Command-R, Embeddings | cohere-ai | ✅ Full Support |
| 🤗 Hugging Face | Open Source Models | @huggingface/inference | ✅ Full Support |
🎯 Covers 85% of enterprise AI usage
💻 Usage Examples
🤖 OpenAI (Most Popular)
import { GuardAIan } from '@guardaian/sdk';
import '@guardaian/sdk/auto';
import OpenAI from 'openai';
GuardAIan.init({ apiKey: 'gai_abc123' });
const openai = new OpenAI({ apiKey: 'sk-...' });
// Automatically tracked: cost, tokens, duration, compliance
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello!' }]
});
// Dashboard shows: $0.006 cost, 150 tokens, 1.2s duration ✅🧠 Anthropic Claude
import Anthropic from '@anthropic-ai/sdk';
const anthropic = new Anthropic({ apiKey: 'sk-ant-...' });
// Automatically tracked with GuardAIan
const message = await anthropic.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1000,
messages: [{ role: 'user', content: 'Analyze this data...' }]
});
// Tracks: Claude-specific pricing, token usage, compliance🔍 Google Gemini (Free Testing)
import { GoogleGenerativeAI } from '@google/generative-ai';
const genAI = new GoogleGenerativeAI('your-api-key');
const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
// Automatically tracked with GuardAIan
const result = await model.generateContent('Explain quantum computing');
// Perfect for free testing - no credit card required!
// Get free key: https://makersuite.google.com/app/apikey☁️ Azure OpenAI (Enterprise)
import OpenAI from 'openai';
const azure = new OpenAI({
apiKey: 'your-azure-key',
baseURL: 'https://your-resource.openai.azure.com/openai/deployments/gpt-4',
defaultQuery: { 'api-version': '2024-02-01' }
});
// Tracked separately as 'azure-openai' service
const response = await azure.chat.completions.create({...});⚙️ Configuration
🔧 Basic Setup
GuardAIan.init({
apiKey: 'gai_abc123', // Required: Your GuardAIan API key
environment: 'production', // Optional: Environment name
projectName: 'my-ai-app', // Optional: Project identifier
debug: false // Optional: Enable debug logging
});🚀 Advanced Configuration
GuardAIan.init({
apiKey: 'gai_abc123',
baseURL: 'https://api.guardaianlabs.com', // Optional: Custom API endpoint
environment: 'production', // Optional: Environment name
projectName: 'my-ai-app', // Optional: Project identifier
debug: false, // Optional: Enable debug logging
batchSize: 10, // Optional: Batch size for API calls
flushInterval: 5000, // Optional: Flush interval in ms
customTags: ['team:ml', 'cost-center:r&d'] // Optional: Custom metadata tags
});🏢 Environment-Specific Setup
// Use environment variables for different stages
GuardAIan.init({
apiKey: process.env.GUARDAIAN_API_KEY,
environment: process.env.NODE_ENV,
projectName: 'your-app-name',
debug: process.env.NODE_ENV !== 'production'
});📊 What Gets Tracked Automatically
💰 Complete Cost Analysis
- Real-time cost calculation with provider-specific pricing
- Token usage breakdown (input/output tokens)
- Cost per model and operation type
- Budget tracking with automatic alerts
⚡ Performance Monitoring
- Response time tracking for optimization
- API call success/failure rates
- Performance comparisons between models
- Usage patterns and trends
🛡️ Compliance & Governance
- Automatic policy enforcement in real-time
- Usage limit monitoring (calls, tokens, spend)
- Model restriction enforcement
- Security scanning and violation alerts
📈 Business Intelligence
- Usage analytics across teams and projects
- Cost optimization insights and recommendations
- Executive reporting with trends and forecasts
- ROI analysis for AI investments
🛡️ Compliance & Governance
GuardAIan automatically enforces your organization's AI policies:
// Your dashboard policies are enforced automatically:
// ❌ Usage Limits: Max 1000 API calls per day
// ❌ Budget Controls: Max $500/month across all AI services
// ❌ Model Restrictions: Only allow GPT-3.5 and Claude-3-haiku
// ❌ Time Restrictions: AI usage only during business hours
// ❌ Content Filtering: Block sensitive data patterns
const response = await openai.chat.completions.create({
model: 'gpt-4', // Might be blocked by policy
messages: [{ role: 'user', content: 'Hello!' }]
});
// Policy violations are automatically:
// 🚨 Logged to your dashboard
// 📧 Sent as alerts to admins
// 📊 Included in compliance reports
// ✅ Your code continues to work normally🔒 Enterprise Security:
- SOC 2 Type II compliant infrastructure
- GDPR compliant data handling
- No sensitive data stored - Only metadata tracked
- API keys encrypted in transit and at rest
💻 TypeScript Support
Full TypeScript definitions included:
import { GuardAIan, TrackingData, GuardAIanOptions } from '@guardaian/sdk';
// Fully typed initialization
const config: GuardAIanOptions = {
apiKey: 'gai_abc123',
environment: 'production',
debug: false
};
GuardAIan.init(config);
// Type-safe manual tracking
const event: TrackingData = {
service: 'openai',
model: 'gpt-4',
operation: 'chat.completion',
inputTokens: 100,
outputTokens: 50,
cost: 0.006
};
await guardaian.track(event);🔧 Manual Tracking & Advanced Usage
Manual Event Tracking
import { GuardAIan } from '@guardaian/sdk';
const guardaian = new GuardAIan({ apiKey: 'gai_abc123' });
// Track custom AI usage
await guardaian.track({
service: 'openai',
model: 'gpt-4',
operation: 'chat.completion',
inputTokens: 100,
outputTokens: 50,
cost: 0.006,
duration: 1200,
metadata: {
userId: 'user123',
feature: 'chat-assistant'
}
});Status Checking & Debugging
// Check if SDK is properly initialized
if (GuardAIan.isInitialized()) {
console.log('✅ GuardAIan is ready!');
}
// Enable debug logging
GuardAIan.init({
apiKey: 'gai_abc123',
debug: true
});
// Console output:
// 🛡️ GuardAIan: Intercepted OpenAI call...
// 💰 Cost: $0.006, Tokens: 150, Duration: 1.2s
// ✅ Successfully sent to dashboard🛡️ Error Handling & Reliability
GuardAIan is designed to never break your AI applications:
🔒 Fail-Safe Design
// Even if GuardAIan is completely down, your AI calls work normally
const response = await openai.chat.completions.create({...});
// ✅ Always works - tracking is an enhancement, not a dependency🔄 Resilient Architecture
- Non-blocking tracking - Network issues don't affect your app
- Automatic retries - Failed tracking calls are retried automatically
- Graceful degradation - Invalid config disables monitoring silently
- Error isolation - GuardAIan errors never bubble up to your code
⚡ Performance
- < 1ms overhead per API call
- Async background processing - non-blocking
- Intelligent batching - efficient network usage
- Memory efficient - automatic cleanup
📖 Getting Started Guide
Step 1: Get Your API Key
- 🚀 Sign up at app.guardaianlabs.com
- 📊 Create a project for your application
- 🔑 Generate API key from the dashboard
- 🛡️ Set up policies (optional but recommended)
Step 2: Install & Initialize
npm install @guardaian/sdk// Add to your application entry point
import { GuardAIan } from '@guardaian/sdk';
import '@guardaian/sdk/auto';
GuardAIan.init({
apiKey: process.env.GUARDAIAN_API_KEY,
environment: process.env.NODE_ENV,
projectName: 'your-app-name'
});Step 3: Verify Setup
// Run a test AI call and check your dashboard
const response = await openai.chat.completions.create({
model: 'gpt-3.5-turbo',
messages: [{ role: 'user', content: 'Hello GuardAIan!' }]
});
// ✅ Check https://app.guardaianlabs.com for the tracked usage🧪 Testing & Development
🔧 Development Setup
// Environment-specific configuration
GuardAIan.init({
apiKey: process.env.NODE_ENV === 'production'
? process.env.GUARDAIAN_PROD_KEY
: process.env.GUARDAIAN_DEV_KEY,
environment: process.env.NODE_ENV,
debug: process.env.NODE_ENV === 'development'
});🧪 Free Testing with Google Gemini
// Perfect for development - no credit card required
import { GoogleGenerativeAI } from '@google/generative-ai';
const genAI = new GoogleGenerativeAI('your-free-api-key');
const model = genAI.getGenerativeModel({ model: 'gemini-1.5-flash' });
const result = await model.generateContent('Test GuardAIan tracking');
// Get free API key: https://makersuite.google.com/app/apikey📚 Documentation & Resources
📖 Documentation
- Complete API Reference - Full SDK documentation
- Quick Start Guide - Get running in 5 minutes
- Provider Setup Guides - Setup for each AI service
- Enterprise Features - Advanced configuration
💬 Community & Support
- GitHub Discussions - Community Q&A
- GitHub Issues - Bug reports and feature requests
- Support Email - Direct technical support
🎥 Learning Resources
- Blog Posts - AI governance insights and tips
- Case Studies - Real customer success stories
📅 Changelog & Roadmap
🚀 Current Version: 1.0.0
- ✅ Universal AI provider support (7 providers)
- ✅ Real-time cost calculation
- ✅ Automatic compliance checking
- ✅ TypeScript definitions
- ✅ Enterprise security features
🔮 Coming Soon
- 🔧 More AI Providers - Stability AI, AI21 Labs
- 📊 Advanced Analytics - Usage forecasting, anomaly detection
- 🔗 Webhook Support - Real-time notifications
- 🌐 Multi-region Support - Global deployment options
📄 License
MIT License - see LICENSE file for details.
Privacy & Security:
🎯 Ready to Get Started?
🚀 Free Trial - No Credit Card Required
# Install and start monitoring in under 2 minutes
npm install @guardaian/sdk
# Sign up and get your API key
# https://app.guardaianlabs.com/signup
# Add these two lines to your app
import { GuardAIan } from '@guardaian/sdk';
import '@guardaian/sdk/auto';
GuardAIan.init({ apiKey: 'your_api_key' });
# Your existing AI code now has complete governance! 🛡️🚀 Start Free Trial • 📚 Read Full Docs • 💬 Get Support
🛡️ The Complete AI Governance Solution
Built for developers who use AI responsibly
⭐ Star this repo if GuardAIan is securing your AI usage!
Made with ❤️ by GuardAIan Labs
