Documentation
Learn how to integrate Niyantra's security layer into your AI applications.
Quick Start
Get up and running with Niyantra in under 5 minutes. Follow these steps to start protecting your LLM requests.
Get your API Key
Sign in to your dashboard and navigate to Settings → API Keys to generate a new key.
Replace your API endpoint
Point your existing OpenAI/Anthropic calls to Niyantra's proxy:
# Before (direct to OpenAI)
https://api.openai.com/v1/chat/completions
# After (through Niyantra)
https://api.niyantra.com/v1/chat/completionsAdd your Niyantra API key
Include your Niyantra key in the X-API-Key header:
const response = await fetch('https://api.niyantra.com/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': 'niy_your_api_key_here',
'Authorization': 'Bearer sk-your-openai-key'
},
body: JSON.stringify({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Hello, world!' }]
})
});All your requests will now be scanned for PII, logged for audit, and optimized for cost. No code changes needed beyond the endpoint swap.
Installation
Install the official Niyantra SDK for your preferred language.
npm install @niyantra/sdkpip install niyantraSDK Usage
import { Niyantra } from '@niyantra/sdk';
const niyantra = new Niyantra({
apiKey: process.env.NIYANTRA_API_KEY,
llmProvider: 'openai',
llmApiKey: process.env.OPENAI_API_KEY,
});
const response = await niyantra.chat.completions.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Analyze this data...' }],
});
console.log(response.pii_detections);PII Detection
Niyantra automatically detects and can redact 70+ types of personally identifiable information before it reaches your LLM.
Supported PII Types
Identity
Contact
Financial
Healthcare
Developer
Network
Detection Modes
Detect Only
Scan and log PII but allow the request to proceed unchanged.
scan_mode: "detect"Redact
Replace detected PII with placeholders before sending to LLM.
scan_mode: "redact"Block
Reject requests containing critical PII (SSN, credit cards, etc).
scan_mode: "block"Chat API
Niyantra's Chat API is fully compatible with OpenAI's format, making migration seamless.
curl -X POST https://api.niyantra.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "X-API-Key: niy_your_key" \
-H "Authorization: Bearer sk-openai-key" \
-d '{
"model": "gpt-4",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is the capital of France?"}
],
"scan_mode": "redact",
"temperature": 0.7
}'Response Format
{
"id": "chatcmpl-abc123",
"model": "gpt-4",
"choices": [
{
"message": {
"role": "assistant",
"content": "The capital of France is Paris."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 25,
"completion_tokens": 12,
"total_tokens": 37
},
"niyantra": {
"pii_detected": [],
"scan_latency_ms": 12,
"request_id": "req_xyz789"
}
}Security
Niyantra is built with security-first principles. All data is processed locally and never stored.
End-to-End Encryption
All traffic is encrypted using TLS 1.3
Zero Data Retention
Request content is never stored or logged
Token-Based Auth
Secure API keys with granular permissions
Rate Limiting
Protection against abuse and DoS attacks
Compliance
Niyantra helps you meet regulatory requirements with built-in compliance features.
Healthcare data protection with PHI detection and audit trails
European data protection with PII redaction and consent management
Indian data protection with Aadhaar, PAN, and ABHA detection
Security controls with comprehensive audit logging