Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


     

# ai-router 🚀

Ultra-light AI API Router - Zero deps, single file, auto failover

GitHub stars Python License


Why ai-router?

Have you ever:

  • 🤯 An AI API goes down and your app crashes with it
  • 😤 Free API quota is exhausted, no auto-fallback to paid
  • 🔄 Want to use multiple AI providers without rewriting integration for each
  • 📦 Just want to make an API call without installing 500MB of dependencies

ai-router is your answer. One file, zero dependencies, deploy anywhere.


Quick Start

Install

pip install git+https://github.com/longongzi/ai-router.git

Or just download the single file:

curl -O https://raw.githubusercontent.com/longongzi/ai-router/main/ai_router.py

Start

export DEEPSEEK_API_KEY="sk-your-key-here"
ai-router serve

Use

OpenAI-compatible API:

from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="-")
response = client.chat.completions.create(
    model="gpt-4o-mini",  # auto-mapped to deepseek-chat
    messages=[{"role": "user", "content": "Hello!"}],
)

Or curl:

curl http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o-mini", "messages": [{"role": "user", "content": "Hello"}]}'

Features

Feature Description
🪶 Zero deps Pure Python stdlib, runs anywhere
🔄 Auto failover Primary down? Switch to backup
🎯 Model aliases Drop-in replacement for any OpenAI SDK
🤝 Multi-provider DeepSeek, OpenClaw, any OpenAI-compatible API
Streaming Native SSE streaming
🐳 Single file One .py, no node_modules, no venv hell
📦 CLI tools Built-in CLI for testing

Why ai-router?

vs ai-router Alternative
LiteLLM 1 file, 0 deps ~50MB deps
OpenRouter Self-hosted Hosted, privacy concerns
Glue code One solution Per-project wrappers

Roadmap

  • Local model support (llama.cpp / Ollama)
  • Load balancing
  • Request caching
  • Rate limiting
  • Docker image

Sponsor

Sponsor

Every sponsorship fuels continued development 🙏


MIT License © 2026 longongzi

Built with ❤️ and ☕

About

One file, zero dependencies. AI model router with automatic failover - deploy anywhere. Self-hosted | OpenAI-compatible

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages