Best Practices

Token management, API key security, data minimization, webhook optimization, and fine-tuning tips

Overview

Following these best practices will help you optimize your ViriSIM integration, reduce costs, improve security, and get the most value from AI observability and compliance.

Token Management

Cost Optimization

Tokens are consumed with each audit submission (max 2,000 tokens per request). Efficient token usage reduces costs and ensures continuous operation.

💰 Token Best Practices

Monitor token usage — Check Analytics → Token Usage dashboard regularly
Optimize payload size — Keep input/output under 1,000 tokens when possible
Set up alerts — Configure low token notifications in Settings → Notifications
Batch processing — Send multiple audits sequentially, not in parallel (one at a time)
Estimate costs — Each token costs less than $0.00001 (varies by plan)
Token Requirements:
  • Manual fine-tuning: 20,000+ tokens
  • Automation: 1,000,000+ tokens
  • Regular audits: As needed based on volume

API Key Security

Authentication
Never hardcode keys — Use environment variables or secret managers
Rotate keys every 90 days — Generate new keys and update your applications
Revoke compromised keys immediately — Delete from Integration → API Keys
Use separate keys per environment — Different keys for development, staging, production
Use descriptive names — "Production API", "Dev Testing" for easy identification
// ✅ DO: Use environment variables
const apiKey = process.env.VIRIDEED_API_KEY;

// ❌ DON'T: Hardcode keys in source code
// const apiKey = "sk-viri-abc123...";  // NEVER DO THIS

Data Minimization

Efficiency

Sending only necessary data reduces token consumption and improves processing speed.

Truncate long inputs — Keep user inputs under 1,500 tokens when possible
Redact PII before sending — Remove emails, phone numbers, addresses
Set country fields accurately — Helps with jurisdiction-specific regulations
Use correct format tags — Set format to "text" or "json" accurately
Token Limit: Maximum 2,000 tokens per submission (input + output combined). Larger requests will be rejected with error Tokens above the limit of 2k. Incorrect requests could incure 10 tokens per request.

Webhook Optimization

Integration
Don't await audit completion — The API returns immediately with a submission_id
Store submission IDs — Reference them later to find results in I/O Logs
Implement retry logic — Use exponential backoff for failed requests
Log errors — Capture and monitor error responses for debugging
Test before production — Use cURL or Postman to verify integration
// ✅ Best practice: Async audit submission
async function submitAudit(userInput, aiOutput) {
    const response = await fetch('https://https://analyzecompliance-vrbinbrbkq-uc.a.run.app', {
        method: 'POST',
        headers: { 'X-API-Key': apiKey, 'Content-Type': 'application/json' },
        body: JSON.stringify(payload)
    });
    
    const result = await response.json();
    const submissionId = result.submission_id;
    
    // Store ID for later reference — don't wait for audit completion
    await saveSubmissionId(submissionId);
    
    // Return immediately — audit runs asynchronously
    return { submissionId, status: 'processing' };
}
Test Webhook: Use the interactive demo on CodePen: ViriSIM Webhook Demo →

Fine-Tuning

Model Improvement
Start with sufficient examples — Minimum 10, recommended 50-500 examples
Use automation for continuous improvement — Schedule weekly or monthly retraining
Select quality training data — Focus on non-compliant audits with clear violations
Monitor job status — Check Fine-Tune → History for job progress
Download audit reports — Save compliance documentation for your records
Use recommended hyperparameters — 3 epochs, auto batch size for most cases
Automation Requirements:
  • Minimum 10 training examples (2+ audit logs)
  • 1,000,000+ tokens required to activate automation
  • If disabled for 3+ cycles, automation will be terminated

Storage Management

Data Retention

ViriSIM provides 1 GB of free storage for audit logs. Proactive management prevents service interruption.

Download logs regularly — Export archives before storage fills up
Delete old logs — Remove logs older than 90 days to free space
Monitor usage — Check Settings → Logs Storage for current usage
Configure storage alerts — Set notifications at 70% (warning) and 90% (critical)
Plan for retention — Logs retained for 7 years (EU AI Act compliance)
Storage Breakdown:
  • AI I/O Logs: ~60% of storage (metadata & compliance audits)
  • Audit Trails: ~30% of storage (regulatory records)
  • API Request Logs: ~10% of storage (calls and analytics)

Integration Security

Safe Connections
Always use HTTPS — Never send API keys over HTTP
Monitor integration logs — Review webhook activity for anomalies
Use IP allowlisting — Restrict API access to trusted IPs (Enterprise feature)
Test with sandbox first — Validate integration before production
Keep dependencies updated — Regular security patches
// ✅ Secure integration example
const apiKey = process.env.VIRIDEED_API_KEY;
const headers = new Headers({
    'X-API-Key': apiKey,
    'Content-Type': 'application/json'
});

const response = await fetch('https://https://analyzecompliance-vrbinbrbkq-uc.a.run.app/', {
    method: 'POST',
    headers: headers,
    body: JSON.stringify(payload)
});

Quick Reference Checklist

Store API keys in environment variables
Rotate keys every 90 days
Monitor token balance regularly
Keep payloads under 2,000 tokens
Store submission IDs for reference
Implement retry logic with backoff
Download and delete logs to manage storage
Test webhooks before production
Enable MFA for admin accounts
Set up notifications for low tokens/storage

Ready to Start Auditing?

Go to ViriSIM, get your API key and run your first compliance audit in under 30 minutes.

Go to ViriSIM