⚡NexusAI-Client

Introduction

Unified, strictly-typed, asynchronous Python 3.12+ gateway for multi-provider AI APIs.

NexusAI-Client ⚡

PyPIPython 3.12+uvTypingLicense

NexusAI-Client is an ultra-lightweight, strictly-typed, asynchronous Python 3.12+ gateway for multi-provider AI APIs. It unifies Cerebras, Cohere, DeepSeek, Google Gemini (Free & Pro), Groq, Mistral, Nvidia NIM, OpenRouter, and OrcaRouter behind a single, elegant interface with zero heavy vendor SDK dependencies.


ðŸ’Ą Why NexusAI-Client?

Modern AI applications frequently need to juggle between multiple LLM providers for cost optimization, high throughput, and high availability. Traditionally, this required installing 9 or 10 separate proprietary SDKs (google-genai, openai, groq, cohere, mistralai, etc.).

This practice leads to:

  • Dozens of conflicting transitive dependencies and bloating container sizes.
  • Incompatible async models and diverging parameter names.
  • Slow startup and excessive memory overhead.

NexusAI-Client fixes this from the ground up:

  • 🔄 Dynamic Model Management & Auto-Rotation: Automatic failover on HTTP 404/400 (deprecated models), HTTP 429 rate limits, and timeouts across models and providers.
  • ðŸŠķ Zero Heavyweight Dependencies: Powered purely by httpx and python-dotenv.
  • ⚡ Native Asynchronous & SSE Streaming: Stream responses token-by-token in real time via stream_text() and stream_chat().
  • 🔄 Zero-Cost-First Smart Fallback: Automatic progression from 100% Free Tiers (Gemini, Groq, Cerebras, Cohere, Nvidia, OpenRouter, OrcaRouter, Mistral) to Paid Backups (AIGateway.auto_fallback()).
  • 🛠ïļ Universal Tool Calling / Function Calling: Standardized function schema, automatic JSON argument parsing, and multi-turn agent loops across Groq, Cerebras, Mistral, DeepSeek, Gemini REST, Cohere V2, and Nvidia NIM.
  • 🚀 World-Record Hardware Accelerators: Tap into Groq LPUs and Cerebras CS-3 Wafer-Scale engines (2,000+ tokens/sec).
  • 🧠 Enterprise Reasoning & Search Models: Native Cohere Command R+, DeepSeek R1, and Qwen 3.8 models.
  • ðŸŽŊ Guaranteed JSON Outputs: Native json_mode=True across all supported providers.
  • 💰 Live Account & Budget Inspection: Inspect real-time balances (USD, NGC credits) and rate limits (RPM, TPM, RPD).
  • 🔍 670+ Models Discovered Live: Automatic detection of free-tier models (:free, -free) and accurate per-million-token pricing.

🌟 1-Minute Quick Start

import asyncio
from nexusai_client import AIGateway

async def main():
    # Automatically discovers active keys in .env and routes: Free -> Free -> Paid
    async with AIGateway.auto_fallback() as client:
        response = await client.generate_text("Explain quantum computing in 2 sentences.")
        print(f"✅ Served by [{response.provider}] with zero downtime:")
        print(response.text)

if __name__ == "__main__":
    asyncio.run(main())

🧭 Explore the Documentation

  • Installation: How to install via pip, uv, or poetry.
  • Configuration: Setting up environment variables and API keys.
  • Providers Matrix: Complete breakdown of all 10 supported providers.
  • Core Features: Streaming, vision analysis, fallback routing, and quota inspections.
  • Cookbooks & Recipes: FastAPI microservices, chat sessions, and background workers.
  • API Reference: Detailed signatures for classes, methods, models, and exceptions.

On this page