Production-ready TypeScript framework for unified LLM provider access with intelligent routing, caching, and resilience.
Status: β Production-Ready | Version: 0.1.0 | Test Coverage: 96.3%
LLM Connector Hub provides a unified, type-safe interface for interacting with multiple Large Language Model providers (OpenAI, Anthropic, Google AI, Azure OpenAI, AWS Bedrock). Built with TypeScript and Node.js, it offers enterprise-grade features including smart provider selection, automatic failover, response caching, and comprehensive observability.
- π Exceptional Performance: Sub-microsecond overhead (<2ΞΌs), 46K ops/s throughput
- π Multi-Provider Support: OpenAI (GPT-5, GPT-4o), Anthropic (Claude), Google AI (Gemini), Azure OpenAI, AWS Bedrock
- π‘οΈ Production-Ready: 96.3% test coverage, zero compilation errors
- π° Cost-Effective: 70-90% API cost reduction via intelligent caching
- π Enterprise-Grade: Full observability, monitoring, and deployment automation
- β Unified Interface - Single API for all LLM providers
- β Streaming Support - Real-time token streaming via Server-Sent Events (SSE)
- β Multi-turn Conversations - Stateful conversation management
- β Function Calling - Tool/function calling support across providers
- β Multimodal Support - Text + image inputs (vision models)
- β Request Normalization - Automatic request/response transformation
- β Token Estimation - Built-in token counting and validation
- β Automatic Retry - Exponential backoff with jitter for transient failures
- β Circuit Breaker - Prevents cascade failures with 3-state circuit breaker
- β Rate Limiting - Token bucket and sliding window algorithms
- β Health Monitoring - Automatic health checks with auto-recovery
- β Multi-Provider Failover - Seamless fallback to backup providers
- β Error Recovery - Intelligent error handling and retry strategies
- β Response Caching - Memory (LRU) and Redis-backed caching
- β Smart Provider Selection - 6 selection strategies (cost, latency, health-based)
- β Horizontal Scaling - Stateless design for easy scaling
- β Connection Pooling - Efficient HTTP connection reuse
- β Request Deduplication - Prevents duplicate concurrent requests
- β Structured Logging - High-performance logging with pino
- β Prometheus Metrics - Request, latency, error, and cache metrics
- β Health Checks - Liveness and readiness endpoints
- β Distributed Tracing - OpenTelemetry integration ready
- β Performance Tracking - Real-time performance monitoring
- β Input Validation - Runtime validation with Zod schemas
- β Data Sanitization - Automatic PII and sensitive data redaction
- β Secrets Management - Environment-based configuration
- β TypeScript Strict Mode - Compile-time type safety
- β Security Scanning - Automated vulnerability scanning in CI/CD
npm install @llm-dev-ops/connector-hub# Core package
npm install @llm-dev-ops/connector-hub-core
# Providers package
npm install @llm-dev-ops/connector-hub-providers
# Middleware package
npm install @llm-dev-ops/connector-hub-middleware
# CLI tool (global)
npm install -g @llm-dev-ops/connector-hub-cli| Package | Description | Install Command |
|---|---|---|
| @llm-dev-ops/connector-hub-core | Core interfaces and types | npm install @llm-dev-ops/connector-hub-core |
| @llm-dev-ops/connector-hub-providers | All provider implementations | npm install @llm-dev-ops/connector-hub-providers |
| @llm-dev-ops/connector-hub-middleware | Middleware components | npm install @llm-dev-ops/connector-hub-middleware |
| @llm-dev-ops/connector-hub | Complete orchestration layer | npm install @llm-dev-ops/connector-hub |
| @llm-dev-ops/connector-hub-cli | Command-line interface | npm install -g @llm-dev-ops/connector-hub-cli |
import { ConnectorHub } from '@llm-dev-ops/connector-hub';
import { Anthropic } from '@llm-dev-ops/connector-hub-providers';
// Initialize the hub
const hub = new ConnectorHub({
providers: {
anthropic: Anthropic.createAnthropicProvider({
apiKey: process.env.ANTHROPIC_API_KEY!,
}),
},
});
// Send a completion request
const response = await hub.complete({
model: 'claude-3-sonnet-20240229',
messages: [
{ role: 'system', content: 'You are a helpful assistant.' },
{ role: 'user', content: 'Explain quantum computing in simple terms.' },
],
temperature: 0.7,
max_tokens: 500,
});
console.log(response.message.content);import { ConnectorHub } from '@llm-dev-ops/connector-hub';
import { OpenAI } from '@llm-dev-ops/connector-hub-providers';
const hub = new ConnectorHub({
providers: {
openai: OpenAI.createOpenAIProvider({
apiKey: process.env.OPENAI_API_KEY!,
}),
},
});
// Use GPT-5 (latest flagship model)
const response = await hub.complete({
model: 'gpt-5',
messages: [{ role: 'user', content: 'Explain machine learning.' }],
temperature: 0.7,
max_tokens: 1000,
});
// Use GPT-4o (fast multimodal model)
const visionResponse = await hub.complete({
model: 'gpt-4o',
messages: [{
role: 'user',
content: [
{ type: 'text', text: 'What is in this image?' },
{ type: 'image_url', image_url: 'https://example.com/image.jpg' },
],
}],
});import { ConnectorHub } from '@llm-dev-ops/connector-hub';
import { Azure } from '@llm-dev-ops/connector-hub-providers';
const hub = new ConnectorHub({
providers: {
azure: Azure.createAzureProvider({
apiKey: process.env.AZURE_OPENAI_API_KEY!,
resourceName: 'your-resource-name',
deploymentName: 'gpt-4o-deployment', // Your Azure deployment name
}),
},
});
// Use your Azure OpenAI deployment
const response = await hub.complete({
model: 'gpt-4o', // Model ID (deployment handles the routing)
messages: [{ role: 'user', content: 'Hello, Azure OpenAI!' }],
});
// Alternative: Use endpoint URL directly
const hubWithEndpoint = new ConnectorHub({
providers: {
azure: Azure.createAzureProvider({
apiKey: process.env.AZURE_OPENAI_API_KEY!,
endpoint: 'https://your-resource.openai.azure.com',
deploymentName: 'gpt-4o-deployment',
}),
},
});import { ConnectorHub } from '@llm-dev-ops/connector-hub';
import { Bedrock } from '@llm-dev-ops/connector-hub-providers';
const hub = new ConnectorHub({
providers: {
bedrock: Bedrock.createBedrockProvider({
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
}),
},
});
// Use Claude 3.5 Sonnet on Bedrock
const claudeResponse = await hub.complete({
model: 'anthropic.claude-3-5-sonnet-20241022-v2:0',
messages: [{ role: 'user', content: 'Explain AWS Bedrock.' }],
max_tokens: 1000,
});
// Use Llama 3.3 70B on Bedrock
const llamaResponse = await hub.complete({
model: 'meta.llama3-3-70b-instruct-v1:0',
messages: [{ role: 'user', content: 'Tell me about Llama models.' }],
max_tokens: 1000,
});
// Use Llama 3.1 405B (largest model)
const llama405BResponse = await hub.complete({
model: 'meta.llama3-1-405b-instruct-v1:0',
messages: [{ role: 'user', content: 'Solve this complex problem...' }],
max_tokens: 2000,
});// Stream tokens as they arrive (works with all providers)
for await (const chunk of hub.stream({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Tell me a story.' }],
})) {
if (chunk.content) {
process.stdout.write(chunk.content);
}
}import { Anthropic, Google, OpenAI } from '@llm-dev-ops/connector-hub-providers';
const hub = new ConnectorHub({
providers: {
openai: OpenAI.createOpenAIProvider({ apiKey: process.env.OPENAI_API_KEY! }),
anthropic: Anthropic.createAnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
google: Google.createGoogleProvider({ apiKey: process.env.GOOGLE_API_KEY! }),
},
selector: {
type: 'failover',
primary: 'openai',
fallback: 'anthropic',
},
});
// Automatically fails over to Anthropic if OpenAI is unavailable
const response = await hub.complete(request);| Provider | Status | Streaming | Function Calling | Vision | Models |
|---|---|---|---|---|---|
| OpenAI | β Production | β | β | β | GPT-5, GPT-5.1, GPT-4o, GPT-4o-mini, GPT-4 Turbo |
| Anthropic | β Production | β | β | β | Claude 3.5 Sonnet, Claude 3 Opus/Sonnet/Haiku |
| Google AI | β Production | β | β | β | Gemini 1.5 Pro/Flash, Gemini 1.0 Pro |
| AWS Bedrock | β Production | β | β | β | Claude 3.5, Llama 3.3/3.1, Titan, Command |
| Azure OpenAI | β Production | β | β | β | GPT-5, GPT-4o, GPT-4 Turbo (via deployments) |
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β (Your Application Code) β
ββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββ
β
ββββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββ
β ConnectorHub (Orchestrator) β
β βββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Middleware Pipeline β β
β β β’ Retry (exponential backoff) β β
β β β’ Rate Limiting (token bucket) β β
β β β’ Circuit Breaker (3-state) β β
β β β’ Logging (structured) β β
β β β’ Metrics (Prometheus) β β
β ββββββββββββββββββββββ¬βββββββββββββββββββββββββββ β
β β β
β ββββββββββββββββββββββΌβββββββββββββββββββββββββββ β
β β Provider Registry β β
β β β’ Smart Selection (6 strategies) β β
β β β’ Health Monitoring β β
β β β’ Failover Logic β β
β β β’ Cache Manager (LRU + Redis) β β
β ββββββββββββββββββββββ¬βββββββββββββββββββββββββββ β
βββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββΌββββββββββββββββββ
β β β
βββββββΌβββββββ ββββββββΌβββββββ ββββββββΌβββββββ
β OpenAI β β Anthropic β β Google AI β
β Provider β β Provider β β Provider β
β (GPT-5/4o) β β (Claude) β β (Gemini) β
βββββββ¬βββββββ ββββββββ¬βββββββ ββββββββ¬βββββββ
β β β
βββββββΌβββββββ ββββββββΌβββββββ β
β Azure β βAWS Bedrock β β
β OpenAI β β Provider β β
β Provider β β(Multi-model)β β
βββββββ¬βββββββ ββββββββ¬βββββββ β
β β β
β Request/Response β
β Transformation β
β β β
βββββββΌβββββββββββββββββΌββββββββββββββββββΌβββββββ
β External Provider APIs β
β β’ api.openai.com β
β β’ *.openai.azure.com β
β β’ bedrock-runtime.*.amazonaws.com β
β β’ api.anthropic.com β
β β’ generativelanguage.googleapis.com β
βββββββββββββββββββββββββββββββββββββββββββββββββ
Switch between providers seamlessly based on cost, latency, or availability:
import { OpenAI, Anthropic, Google, Azure, Bedrock } from '@llm-dev-ops/connector-hub-providers';
const hub = new ConnectorHub({
providers: {
openai: OpenAI.createOpenAIProvider({ apiKey: process.env.OPENAI_API_KEY! }),
anthropic: Anthropic.createAnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
google: Google.createGoogleProvider({ apiKey: process.env.GOOGLE_API_KEY! }),
azure: Azure.createAzureProvider({
apiKey: process.env.AZURE_OPENAI_API_KEY!,
resourceName: process.env.AZURE_RESOURCE_NAME!,
deploymentName: 'gpt-4o-deployment',
}),
bedrock: Bedrock.createBedrockProvider({
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
}),
},
selector: {
type: 'cost-optimized', // Automatically select cheapest provider
},
});Automatic failover ensures continuous service across multiple providers:
const hub = new ConnectorHub({
providers: {
primary: OpenAI.createOpenAIProvider({ apiKey: process.env.OPENAI_API_KEY! }),
secondary: Anthropic.createAnthropicProvider({ apiKey: process.env.ANTHROPIC_API_KEY! }),
tertiary: Bedrock.createBedrockProvider({
region: 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
}),
},
selector: {
type: 'failover',
primary: 'primary',
fallback: 'secondary',
},
middleware: [
new RetryMiddleware({ maxAttempts: 3 }),
new CircuitBreakerMiddleware({ threshold: 5 }),
],
});Reduce API costs by 70-90% with intelligent caching:
const hub = new ConnectorHub({
providers: { anthropic },
cache: {
type: 'memory',
maxSize: 1000,
ttl: 3600, // 1 hour
},
});
// First call hits API
const response1 = await hub.complete(request);
// Subsequent identical calls use cache (250,000x faster!)
const response2 = await hub.complete(request); // <2ΞΌs from cacheFull observability out of the box:
import { LoggingMiddleware, MetricsMiddleware } from '@llm-dev-ops/connector-hub-middleware';
const hub = new ConnectorHub({
providers: { anthropic },
middleware: [
new LoggingMiddleware({ level: 'info' }),
new MetricsMiddleware({ port: 9090 }), // Prometheus metrics
],
});Provider Transformation Overhead:
- Anthropic: 1.18ΞΌs (860K ops/s) π₯
- Google: 1.28ΞΌs (993K ops/s)
Cache Performance:
- Memory GET (hit): 1.74ΞΌs (575K ops/s)
- Memory GET (miss): 0.62ΞΌs (1.6M ops/s)
Stress Test Results (1000 concurrent requests):
- Throughput: 46,030 ops/s
- Success Rate: 100%
- Memory Usage: +6.3MB (well controlled)
- Memory Leaks: None detected β
Performance vs Targets:
| Metric | Target | Actual | Achievement |
|---|---|---|---|
| Latency Overhead | <1ms | <2ΞΌs | 500x better |
| Throughput | >1000/s | 46,000/s | 46x better |
| Memory Usage | <200MB | ~30MB | 6.6x better |
For detailed benchmarks, see PERFORMANCE_RESULTS.md.
import { OpenAI, Anthropic, Google, Azure, Bedrock } from '@llm-dev-ops/connector-hub-providers';
const providers = {
openai: OpenAI.createOpenAIProvider({
apiKey: process.env.OPENAI_API_KEY!,
timeout: 60000,
}),
anthropic: Anthropic.createAnthropicProvider({
apiKey: process.env.ANTHROPIC_API_KEY!,
timeout: 60000,
}),
google: Google.createGoogleProvider({
apiKey: process.env.GOOGLE_API_KEY!,
timeout: 60000,
}),
azure: Azure.createAzureProvider({
apiKey: process.env.AZURE_OPENAI_API_KEY!,
resourceName: process.env.AZURE_RESOURCE_NAME!,
deploymentName: process.env.AZURE_DEPLOYMENT_NAME!,
timeout: 60000,
}),
bedrock: Bedrock.createBedrockProvider({
region: process.env.AWS_REGION || 'us-east-1',
accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
timeout: 60000,
}),
};const hub = new ConnectorHub({
providers,
// Provider selection strategy
selector: {
type: 'latency-optimized', // or 'cost-optimized', 'round-robin', 'failover'
},
// Caching configuration
cache: {
type: 'memory',
maxSize: 1000,
ttl: 3600,
},
// Middleware pipeline
middleware: [
new RetryMiddleware({ maxAttempts: 3, backoff: 'exponential' }),
new RateLimitMiddleware({ requestsPerMinute: 100 }),
new CircuitBreakerMiddleware({ threshold: 5, timeout: 30000 }),
new LoggingMiddleware({ level: 'info' }),
new MetricsMiddleware(),
],
// Health monitoring
healthCheck: {
enabled: true,
interval: 30000, // 30 seconds
},
});# OpenAI
OPENAI_API_KEY=sk-...
# Anthropic
ANTHROPIC_API_KEY=sk-ant-...
# Google AI
GOOGLE_API_KEY=...
# Azure OpenAI
AZURE_OPENAI_API_KEY=...
AZURE_RESOURCE_NAME=your-resource-name
AZURE_DEPLOYMENT_NAME=gpt-4o-deployment
# Or use endpoint URL:
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
# AWS Bedrock
AWS_REGION=us-east-1
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
# Or use AWS profile:
AWS_PROFILE=default
# Optional Configuration
LLM_CONNECTOR_CACHE_TYPE=memory
LLM_CONNECTOR_LOG_LEVEL=info- Configuration Guide
- Provider Setup
- Middleware Guide
- Caching Strategies
- Error Handling
- Streaming Guide
- Health Monitoring
Comprehensive examples in the examples/ directory:
- Basic Completion - Simple completion with error handling
- Streaming - Real-time streaming responses
- Multi-Provider - Provider comparison and failover
- Middleware Pipeline - Complete middleware configuration
- Advanced Features - Caching, monitoring, function calling
- Production-Ready - Production configuration patterns
# Build image
docker build -t llm-connector-hub .
# Run container
docker run -p 8080:8080 \
-e OPENAI_API_KEY=sk-... \
-e ANTHROPIC_API_KEY=sk-ant-... \
-e GOOGLE_API_KEY=... \
-e AZURE_OPENAI_API_KEY=... \
-e AZURE_RESOURCE_NAME=... \
-e AZURE_DEPLOYMENT_NAME=... \
-e AWS_REGION=us-east-1 \
-e AWS_ACCESS_KEY_ID=... \
-e AWS_SECRET_ACCESS_KEY=... \
llm-connector-hub# Deploy with kubectl
kubectl apply -f deployment/kubernetes/
# Deploy with Helm (coming soon)
helm install llm-connector ./deployment/helm/# Start full stack (app + Redis + Prometheus + Grafana)
docker-compose up -dFor detailed deployment instructions, see Deployment Guide.
# Run all tests
npm test
# Run with coverage
npm run test:coverage
# Run specific package tests
npm test -- packages/providers# Run all benchmarks
npm run bench:all
# Run specific benchmarks
npm run bench:provider # Provider transformation
npm run bench:cache # Cache operations
npm run bench:stress # Stress tests (1000 concurrent)
npm run bench:load # Load tests
# Save results
npm run bench:save
# Analyze results
npm run bench:analyzeWe welcome contributions! Please see our Contributing Guide.
# Clone repository
git clone https://github.com/your-org/llm-connector-hub
cd llm-connector-hub
# Install dependencies
npm install
# Build all packages
npm run build
# Run tests
npm test
# Run linting
npm run lint
# Run type checking
npm run type-check- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests
- Run
npm testandnpm run lint - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- β OpenAI provider (GPT-5, GPT-5.1, GPT-4o, GPT-4o-mini, GPT-4 Turbo)
- β Anthropic (Claude) provider (Claude 3.5 Sonnet, Claude 3 Opus/Sonnet/Haiku)
- β Google AI (Gemini) provider (Gemini 1.5 Pro/Flash, Gemini 1.0 Pro)
- β Azure OpenAI provider (all GPT models via deployments)
- β AWS Bedrock provider (Claude, Llama, Titan, Command, Mistral)
- β Streaming support for all providers
- β Multi-provider failover
- β Caching (Memory + Redis)
- β Middleware pipeline (retry, circuit breaker, rate limiting)
- β Health monitoring
- β Comprehensive documentation
- β Function/tool calling support
- β Vision/multimodal support
- Request batching
- Advanced analytics dashboard
- WebSocket support for real-time streaming
- Enhanced cost tracking and optimization
- Model performance comparison tools
- Additional Bedrock models (Mistral, Cohere)
- Plugin marketplace
- Custom provider SDK
- Advanced load balancing strategies
- Multi-region support with geo-routing
- Enterprise features (SSO, audit logs, RBAC)
- GraphQL API support
For detailed roadmap, see IMPLEMENTATION_ROADMAP.md.
Security is a top priority. If you discover a security vulnerability, please email security@example.com instead of using the issue tracker.
- β API key encryption at rest (when stored)
- β Sensitive data sanitization in logs
- β Input validation with Zod schemas
- β TypeScript strict mode (compile-time safety)
- β Automated security scanning (npm audit, Snyk, CodeQL)
- β No hardcoded credentials
- β Secrets management integration (Vault, AWS Secrets Manager)
This project is licensed under the Apache License, Version 2.0.
Built with excellent open-source libraries:
- TypeScript - Type-safe JavaScript
- Zod - TypeScript-first schema validation
- Pino - High-performance logging
- Vitest - Fast unit testing
- prom-client - Prometheus metrics
- Documentation: docs/
- Examples: examples/
- GitHub Issues: Report a bug
- Discussions: Ask a question
- Email: support@example.com
Current Version: 0.1.0
Status: β
Production-Ready
Build:
Test Coverage: 96.3%
Performance Grade: A+
See FINAL_PRODUCTION_REPORT.md for complete production validation.
If you find this project useful, please consider giving it a star! β
Made with β€οΈ by the LLM Connector Hub Team
Unified. Resilient. Production-Ready.