@know-your-ai/core
v0.1.0
Published
Core library for Know Your AI SDK - AI model interception and monitoring
Maintainers
Readme
@know-your-ai/core
Core library for the Know Your AI SDK. This package provides the foundational components for AI monitoring and instrumentation.
Installation
This package is typically used through @know-your-ai/node. Direct installation is only needed for advanced use cases.
npm install @know-your-ai/coreQuick Start
Initialize the SDK with your API key obtained from the Know Your AI dashboard:
import * as KnowYourAI from '@know-your-ai/node';
KnowYourAI.init({
apiKey: 'kya_your_api_key_here',
integrations: [
KnowYourAI.googleGenAIIntegration(),
],
});
// Your AI code will now be automatically monitoredGetting Your API Key
- Go to the Know Your AI dashboard
- Navigate to your Workspace > Products
- Select or create a Product
- Go to Settings > API Keys
- Create a new API key
- Copy the key (it will only be shown once!)
Configuration Options
KnowYourAI.init({
// Required: Your API key from Know Your AI dashboard
apiKey: 'kya_...',
// Optional: Custom endpoint (defaults to Know Your AI backend)
endpoint: 'https://api.knowyourai.dev/sdk/events',
// Optional: Environment identifier
environment: 'production', // 'development', 'staging', etc.
// Optional: Control what data is captured
recordInputs: true, // Capture input messages
recordOutputs: true, // Capture AI responses
// Optional: Sampling rate (0.0 to 1.0)
sampleRate: 1.0,
// Optional: Enable debug logging
debug: false,
// Optional: Batch settings
batchSize: 10, // Events to batch before sending
flushInterval: 5000, // Max time (ms) to wait before flushing
// Required: Integrations to use
integrations: [
KnowYourAI.googleGenAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
],
});What's Included
- Client - Core client for managing integrations and capturing data
- Integrations - Plugin system for adding AI provider support
- Transports - Data transport implementations (HTTP, console, Know Your AI backend)
- Types - TypeScript type definitions
- Utilities - Helper functions and debug utilities
Available Transports
Know Your AI Transport (Default)
Automatically configured when using apiKey option.
HTTP Transport
For custom endpoints:
import { createHttpTransport } from '@know-your-ai/core';
const transport = createHttpTransport({
endpoint: 'https://your-custom-endpoint.com/events',
apiKey: 'your-custom-api-key',
});Console Transport (Debugging)
import { createConsoleTransport } from '@know-your-ai/core';
const transport = createConsoleTransport();License
MIT
