@apixauth/protocol
v1.0.5
Published
Secure AI API authentication, rate limiting, and cost control - Zero infrastructure, maximum security!
Maintainers
Readme
🔐 APIxAuth Protocol
Secure AI API authentication, rate limiting, and cost control - Zero infrastructure, maximum security!
🚀 Features
- 🔒 5-Layer Security - Clone keys, device fingerprinting, encryption, request signing, domain whitelisting
- ⚡ Zero Infrastructure - No servers, no databases by default (optional encrypted storage)
- 🤖 Multi-Provider - Gemini, OpenAI, Claude with auto-fallback
- 💰 Cost Control - Real-time tracking, budget limits, automatic downgrade
- 📊 Rate Limiting - Smart quota management with ML-based learning
- 🔍 Built-in Search - Google Search (Gemini), Web browsing (GPT-4o)
- 🧠 Deep Thinking - Reasoning modes (o1/o3/o4, Gemini thinking)
- 📝 Audit Logging - Cryptographically signed request logs
- 🎯 39 AI Models - Latest models from all providers (Feb 2026)
📦 Installation
npm install @apixauth/protocolOptional Dependencies (Auto-updates)
# For always-updated AI models
npm install @google/generative-ai openai @anthropic-ai/sdk
# For database storage
npm install pg mysql2 mongodb sqlite3🎯 Quick Start
import { APIxAuth } from '@apixauth/protocol';
const api = new APIxAuth({
providers: {
gemini: {
key: process.env.GEMINI_API_KEY,
dailyLimit: 100
},
openai: {
key: process.env.OPENAI_API_KEY,
dailyLimit: 200
}
},
budget: {
daily: 10.00,
perRequest: 1.00
}
});
// Basic chat
const response = await api.chat('Hello!');
console.log(response.text);
// Chat with search
const searchResponse = await api.chatWithSearch('Latest AI news 2026?');
// Chat with thinking
const thinkingResponse = await api.chatWithThinking('Solve: 2x + 5 = 15');🔐 Key Vault Security
Protect your API keys with 5-layer security:
const api = new APIxAuth({
keyVault: {
enabled: true,
masterPassword: process.env.MASTER_PASSWORD,
allowedDomains: ['myapp.com']
},
providers: {
gemini: { key: 'AIzaSy...' } // Real key
}
});
// After initialization, real key is encrypted
// Code now contains: axk_1a2b3c4d... (clone key)
// Clone key is useless if stolen - device-locked!Security Layers:
- AES-256-GCM Encryption - Military-grade
- Clone Keys - Safe references (axk_*)
- Device Fingerprinting - Hardware-locked
- Request Signing - Timestamp + nonce
- Domain Whitelisting - Authorized domains only
💡 Use Cases
Express.js API
import express from 'express';
import { APIxAuth } from '@apixauth/protocol';
const app = express();
const api = new APIxAuth({ /* config */ });
app.post('/api/chat', async (req, res) => {
const response = await api.chat(req.body.message);
res.json(response);
});SaaS Application
// Per-user rate limiting
const api = new APIxAuth({
providers: {
gemini: { key: user.apiKey, dailyLimit: user.plan.limit }
}
});Batch Processing
const messages = ['Question 1', 'Question 2', 'Question 3'];
const responses = await Promise.all(
messages.map(msg => api.chat(msg))
);📊 Supported Models (Feb 2026)
Gemini (17 models)
gemini-2.5-flash(default) - Fast & efficientgemini-2.5-pro- Most capablegemini-2.0-flash-thinking-exp- Deep reasoning- Image:
gemini-2.5-flash-image,imagen-4.0 - Video:
veo-3.1,veo-3.0
OpenAI (11 models)
gpt-4o(default) - Latest GPT-4gpt-4.5,gpt-4.5-pro- Most advancedo4-mini,o3,o3-pro- Reasoning modelsgpt-4.1,gpt-4.1-mini- Coding focused
Claude (11 models)
claude-sonnet-4.5(default) - Balancedclaude-opus-4.5- Most capableclaude-haiku-4.5- Fastestclaude-4.1series
🎨 Features
Built-in Search
// Google Search grounding (Gemini)
const response = await api.chatWithSearch('Latest tech news?', {
provider: 'gemini'
});
// Web browsing (GPT-4o)
const response = await api.chatWithSearch('Current Bitcoin price?', {
provider: 'openai'
});Deep Thinking Mode
// Gemini thinking mode
const response = await api.chatWithThinking('Complex math problem', {
provider: 'gemini'
});
// OpenAI o1/o3/o4 reasoning
const response = await api.chatWithThinking('Logic puzzle', {
provider: 'openai',
model: 'o4-mini'
});
console.log(response.thinkingContent); // See reasoning processCost Tracking
// Get usage stats
const usage = await api.getUsage();
console.log(usage.cost); // Total cost
console.log(usage.quotas); // Per-provider quotas
// Get total cost
const cost = await api.getCost();
console.log(`Spent: $${cost.toFixed(2)}`);Database Storage
const api = new APIxAuth({
storage: {
type: 'database',
options: {
type: 'postgresql',
connection: {
host: 'localhost',
database: 'apixauth',
user: 'user',
password: 'pass'
},
encryptionKey: process.env.ENCRYPTION_KEY
}
}
});📚 Documentation
- Quick Start Guide
- Key Vault Explained
- Integration Guide
- Search Feature
- Thinking Mode
- All Models (2026)
- API Reference
- Architecture
🛠️ Development
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Lint
npm run lint🤝 Contributing
Contributions are welcome! Please read CONTRIBUTING.md first.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📝 License
MIT © APIxAuth
🌟 Star History
If you find this project useful, please consider giving it a star! ⭐
📧 Support
🎯 Roadmap
- [ ] Next.js support (browser + edge runtime)
- [ ] Streaming responses
- [ ] Function calling support
- [ ] Multi-modal inputs (images, audio)
- [ ] Agent workflows
- [ ] More AI providers
Made with ❤️ by the APIxAuth team
