High-performance AI infrastructure with semantic caching and sovereign governance.
Project description
๐ Nexus Gateway Python SDK
Sovereign AI Infrastructure for the Modern Edge
One line of code to reduce LLM latency by 95%, costs by 90%, and enforce deterministic governance at the edge.
Key Metrics at a Glance
โก Why Nexus Gateway?
Real-World Impact
| Metric | Before | After | Improvement |
|---|---|---|---|
| API Latency | 1200ms+ | 5ms | 99.6% โ |
| Cost per Call | Full Price | Near Zero | 90% โ |
| Failover Time | Single Point | <100ms | Self-Healing |
| Data Privacy | None | AES-256 | Enterprise-Grade |
Core Features
Semantic Caching (Layer 0 & 1)
Intelligent hybrid caching with Redis & Pinecone. Get responses in <5ms by eliminating redundant API calls.
Cache Hit: 5ms โก
Network Round Trip: 1200ms ๐ข
Savings per hit: 100% ๐ฐ
๐ค DeepSeek Native Streaming
Full support for OpenAI-compatible reasoning models with Thinking Tokens streaming directly to your terminal.
๐ Adaptive Universal Router
Single API signature, infinite model combinations:
- Groq โ Lightning-fast inference
- Google Gemini โ Multimodal powerhouse
- OpenAI โ Production reliability
- Anthropic Claude โ Reasoning excellence
Automatic failover with self-healing load balancing.
๐ก๏ธ Sovereign Shield (v3.0)
Enterprise-grade governance at the edge:
- โ PII redaction before API calls
- โ Deterministic data governance
- โ AES-256 encryption
- โ Audit logging
- โ Compliance-ready
๐ Multi-Provider BYOK
Bring Your Own Key to bypass Nexus credits entirely. Use provider billing directly with zero overhead.
๐ Quick Start
1๏ธโฃ Installation
pip install nexus-gateway
2๏ธโฃ Get Your API Key
Head to Nexus Dashboard and grab your provisioned key.
3๏ธโฃ Initialize the Client
from nexus_gateway import NexusClient
client = NexusClient(api_key="nk-your-key-here")
4๏ธโฃ Start Streaming (Your First Call)
# Works with DeepSeek, Groq, Gemini, Claude, GPT-4...
# Same syntax. Zero friction.
stream = client.chat(
model="deepseek-r1",
message="Explain the architecture of a multi-currency reconciliation engine.",
stream=True
)
for token in stream:
print(token, end="", flush=True)
Usage Examples
Real-Time Streaming with Auto-Fallback
# Automatic failover if primary model is unavailable
response = client.chat(
model="gpt-4o",
message="Analyze this market trend...",
stream=True,
fallback_model="claude-3-5-sonnet-latest" # Automatic pivot
)
for chunk in response:
print(chunk, end="", flush=True)
BYOK Mode (Zero-Cost Scaling)
# Skip Nexus credits entirely. Use your own provider API keys.
response = client.chat(
model="gpt-4o",
message="Summarize legal implications of AI governance.",
provider_key="sk-your-openai-key", # ๐ Your credentials
stream=False
)
print(response)
Semantic Caching in Action
# First call: Hits the API, caches the embedding
response1 = client.chat(
model="llama-3.3-70b",
message="What is machine learning?",
cache=True # Enable semantic caching
)
# Second call: Semantically similar query
# โก Cache hit in 5ms! No API call needed.
response2 = client.chat(
model="llama-3.3-70b",
message="Define machine learning for beginners.",
cache=True
)
Sovereign Shield (Data Privacy)
# Automatic PII redaction before API calls
response = client.chat(
model="gpt-4o",
message="My email is john@example.com. Help me with...",
sovereign_shield=True # ๐ก๏ธ Auto-redacts PII
)
# โ John's email never leaves your infrastructure
๐ ๏ธ Interactive CLI Tool
Launch the Nexus Sovereign Shell:
nexus
Available Commands
| Command | Example | Purpose |
|---|---|---|
/model [name] |
/model r1 |
Switch inference engine on-the-fly |
/key [sk-...] |
/key sk-proj-123abc |
Inject BYOK provider credentials |
/cache [on/off] |
/cache on |
Toggle semantic caching |
/shield [on/off] |
/shield on |
Toggle PII redaction |
/history |
/history |
View session messages |
/clear |
/clear |
Wipe session history |
/exit |
/exit |
Close secure data plane |
Example Session:
Nexus> /model gpt-4o
โ Switched to gpt-4o
Nexus> What are the top 3 AI trends in 2025?
[Response streaming...]
Nexus> /key sk-your-openai-key
โ BYOK credentials loaded. Nexus credits bypassed.
Nexus> /shield on
โ Sovereign Shield enabled. PII redaction active.
๐๏ธ Supported Infrastructure Engines
Deploy across the world's fastest inference providers with zero code changes. Nexus handles routing, failover, and optimization automatically.
| Provider | Engine Tier | Core Models | Specialty |
|---|---|---|---|
| DeepSeek | Reasoning (R1) | deepseek-r1, deepseek-v3 |
๐ง Extended Thinking, Math & Logic |
| Groq | Ultra-Fast (Llama) | llama-3.3-70b-versatile, llama-3.1-8b-instant |
โก Sub-100ms Latency, Token Streaming |
| Adaptive (Gemini) | gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash |
๐ฌ Multimodal, Vision, Audio | |
| Anthropic | Reasoning (Claude) | claude-3-5-sonnet-latest, claude-3-opus-20240229 |
๐ฌ Constitutional AI, Lengthy Context |
| OpenAI | Standard (GPT) | gpt-4o, gpt-4o-mini, gpt-4-turbo |
๐ Industry Standard, Production Proven |
Provider Decision Matrix
Speed Champion: Groq (llama-3.3-70b) โ <100ms
Reasoning Champion: DeepSeek R1 โ Advanced problem-solving
Vision Champion: Google Gemini 2.0 โ Image/Video understanding
Cost Champion: OpenAI gpt-4o-mini โ Budget-friendly
Reliability Champion: OpenAI gpt-4o โ Enterprise SLA
๐ Authentication & Security
Step 1: Register
Head to Nexus Gateway Dashboard and sign up.
Step 2: Create API Key
Generate a provisioned key (nk-...) from your dashboard.
Step 3: Store Securely
# Set as environment variable (recommended)
export NEXUS_API_KEY="nk-your-key-here"
Step 4: Initialize
from nexus_gateway import NexusClient
import os
client = NexusClient(api_key=os.getenv("NEXUS_API_KEY"))
Security Features
- ๐ AES-256 Encryption at rest and in transit
- ๐ก๏ธ PII Redaction before provider APIs
- ๐ Audit Logging for compliance
- ๐ BYOK Support for zero trust architectures
- โฑ๏ธ Key Rotation friendly
๐ Performance Benchmarks
Latency Comparison
Nexus Gateway (Cache Hit): 5ms โโโโโโโโโโโโโโโโโโโโโโ
OpenAI SDK (Network): 1200ms โโโโโโโโโโโโโโโโโโโโโโโโ
Improvement: 99.6% ๐
Cost Reduction
Standard Provider Calls: $0.001/call
Nexus Cached Calls: $0.000/call (after first hit)
Annual Savings (10M calls): $10,000 ๐ฐ
๐ Documentation & Resources
| Resource | Link |
|---|---|
| ๐ Full Documentation | nexus-gateway.org/docs |
| ๐ฎ Interactive Dashboard | nexus-gateway.org/dashboard |
| ๐ฌ GitHub Issues | ANANDSUNNY0899/NexusGateway |
| ๐ Report a Bug | Issues |
| ๐ก Request Features | Discussions |
๐ค Community & Support
- Slack Community: Join thousands of developers here
- Office Hours: Thursdays 2 PM UTC on Discord
- Email Support: support@nexus-gateway.org
๐ License & Attribution
Licensed under the MIT License โ free for commercial and personal use.
ยฉ 2025 Sunny Anand
Mission Control ยท Docs ยท GitHub
๐ฏ Getting Started Right Now
# 3 lines to production
from nexus_gateway import NexusClient
client = NexusClient(api_key="nk-your-key")
print(client.chat(model="gpt-4o", message="Hello, Nexus!"))
Ready to reduce latency by 95%? Get your API key โ
Made with ๐ฅ by the Nexus team
Sovereign AI Infrastructure for developers who demand performance, privacy, and control.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nexus_gateway-3.1.5.tar.gz.
File metadata
- Download URL: nexus_gateway-3.1.5.tar.gz
- Upload date:
- Size: 13.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb577d0b9668b850dd7b9e6e3151e489239f4224b15fc71daed7a4a4c67e6ed8
|
|
| MD5 |
08db3fd862d2a6f67e219196ae6f2f89
|
|
| BLAKE2b-256 |
16e916a4c202c2ffe436ec091d2602263f7f025f4b966b6f253ed59765fbce97
|
File details
Details for the file nexus_gateway-3.1.5-py3-none-any.whl.
File metadata
- Download URL: nexus_gateway-3.1.5-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0baa6649d1f44aaca19da793db96ad2369366aeb5931f2c63a060b63c1660a41
|
|
| MD5 |
f0de3d76754fb8edef67add571ef4899
|
|
| BLAKE2b-256 |
d8340c210ada3326b1e372a826055e98bccdda18b3be56c470430ffa2f18aee2
|