Skip to main content

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

PyPI version License: MIT Infrastructure Status Python 3.8+ Latency


โšก 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
Google 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


๐Ÿ“„ 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.

โญ Star us on GitHub ยท ๐Ÿ“ง Stay Updated

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nexus_gateway-3.1.5.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nexus_gateway-3.1.5-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

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

Hashes for nexus_gateway-3.1.5.tar.gz
Algorithm Hash digest
SHA256 bb577d0b9668b850dd7b9e6e3151e489239f4224b15fc71daed7a4a4c67e6ed8
MD5 08db3fd862d2a6f67e219196ae6f2f89
BLAKE2b-256 16e916a4c202c2ffe436ec091d2602263f7f025f4b966b6f253ed59765fbce97

See more details on using hashes here.

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

Hashes for nexus_gateway-3.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 0baa6649d1f44aaca19da793db96ad2369366aeb5931f2c63a060b63c1660a41
MD5 f0de3d76754fb8edef67add571ef4899
BLAKE2b-256 d8340c210ada3326b1e372a826055e98bccdda18b3be56c470430ffa2f18aee2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page