DEV Community

ujjwal Chaudhary
ujjwal Chaudhary

Posted on

I Built a Free OpenRouter Alternative — Here's How

I Built a Free OpenRouter Alternative — Here's How

The Problem

I was paying $50+/month for AI APIs. OpenRouter, OpenAI, Anthropic — it adds up fast.

As a developer, I needed a better solution. Something free, self-hosted, and with no vendor lock-in.

The Solution: MiniRouter

I built MiniRouter — a self-hosted LLM gateway that aggregates 16+ free cloud AI providers into one OpenAI-compatible API.

Cost: $0 forever.

What It Does

MiniRouter sits between your app and AI providers. Instead of calling OpenAI directly, you call MiniRouter. It then routes your request to the best available free provider.

Your App → MiniRouter → Gemini (free)
                     → Groq (free)
                     → Mistral (free)
                     → ... 13 more
Enter fullscreen mode Exit fullscreen mode

Features

  • 16+ Free Providers: Gemini, Groq, Mistral, Cerebras, SambaNova, Together, HuggingFace, OpenRouter, Cloudflare, DeepSeek, xAI, Cohere, Moonshot, Zhipu, Baidu, Alibaba
  • OpenAI Compatible: Works with any OpenAI library (Python, JavaScript, Go, etc.)
  • User Management: Create accounts, set daily limits, track usage
  • Smart Failover: If one provider is down, automatically switches to the next
  • Health Dashboard: See provider status, usage analytics, cost savings
  • Docker Support: One command to deploy

Quick Start

1. Clone and Run

git clone https://github.com/ujjwalchaudhary/mini-router.git
cd mini-router
python -m src
Enter fullscreen mode Exit fullscreen mode

2. Get Free API Keys

3. Add Keys to config.json

{
  "providers": {
    "gemini": {"api_key": "YOUR_KEY"},
    "groq": {"api_key": "YOUR_KEY"}
  }
}
Enter fullscreen mode Exit fullscreen mode

4. Use It

import openai

client = openai.OpenAI(
    base_url="http://localhost:8080/v1",
    api_key="mr-your-api-key"
)

response = client.chat.completions.create(
    model="gemini/gemini-2.0-flash",
    messages=[{"role": "user", "content": "Hello!"}]
)
print(response.choices[0].message.content)
Enter fullscreen mode Exit fullscreen mode

Why Not Just Use OpenRouter?

Feature OpenRouter MiniRouter
Monthly cost $10+ $0
Self-hosted No Yes
Data privacy Shared Full control
User management Basic Full dashboard
Cost tracking No Yes

Use Cases

  • Startups: Save runway by using free AI infrastructure
  • Healthcare: Self-hosted means patient data never leaves your server
  • Education: Give students access to AI without budget approval
  • Personal projects: Build AI apps without monthly costs

Architecture

┌─────────────────────────────────────────┐
│            MiniRouter Server             │
│         (Pure Python, zero deps)        │
├─────────────────────────────────────────┤
│  OpenAI-Compatible API                  │
│  POST /v1/chat/completions              │
├─────────────────────────────────────────┤
│  Smart Router                           │
│  Priority → Provider → Failover → Cache │
├─────────────────────────────────────────┤
│  16 Provider Adapters                   │
│  Gemini, Groq, Mistral, Cerebras, ...   │
└─────────────────────────────────────────┘
Enter fullscreen mode Exit fullscreen mode

What's Next

  • More providers
  • Better analytics
  • Web UI for non-technical users
  • Agent-specific features (tool caching, memory)

Try It

GitHub: https://github.com/ujjwalchaudhary/mini-router

Star it if you find it useful!


Built with ❤️ by a developer tired of expensive AI APIs.

Top comments (0)