Skip to content

Latest commit

 

History

21 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Gateway

Open-source AI orchestration service. One API, multiple AI providers.

Features

  • Multiple AI providers (Gemini, Groq, Mistral, OpenRouter, OpenCodeZen, Zydit, Zai, Agnes, Nvidia)
  • Automatic failover when a provider fails
  • Rate limiting (15 requests/minute per IP)
  • Token authentication
  • Load balancing across providers
  • OpenAI-compatible API format

Quick Start

# Clone
git clone https://github.com/bilalshemsu1/ai-gateway.git
cd ai-gateway

# Install
npm install

# Setup environment
cp .env.example .env
# Edit .env with your API keys and auth token

# Run
npm start

Environment Variables

Create .env file:

# Auth (required)
API_SECRET=your-secret-token

# AI Providers (at least one required)
GEMINI_API_KEY=your_key
GROQ_API_KEY=your_key
MISTRAL_API_KEY=your_key
OPENROUTER_API_KEY=your_key
OPENCODE_API_KEY=your_key
ZYDIT_API_KEY=your_key
ZAI_API_KEY=your_key
AGNES_API_KEY=your_key
NVIDIA_API_KEY=your_key

Get free API keys:

API

The full API reference, request bodies, responses, errors, and examples are in docs/API.md.

Quick start:

curl -X POST http://localhost:3001/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your-api-secret" \
  -d '{
    "model": "auto",
    "messages": [
      {"role": "user", "content": "Hello"}
    ]
  }'

How It Works

User Request
    ↓
Auth Check (Authorization: Bearer <token>)
    ↓
Rate Limit Check
    ↓
Provider Selection (least busy)
    ↓
Try Provider → Success? Return answer
            → Fail? Try next provider
    ↓
All providers failed? Return error

Supported Providers

Provider Free Tier Speed
Groq 14,400 req/day Very Fast
Gemini 60 req/min Fast
Mistral Yes Fast
OpenRouter Varies Medium
OpenCodeZen Yes Medium
Zydit Yes Fast
Zai Yes Fast
Agnes Yes Fast
Nvidia Yes Fast

License

ISC

About

Open-source AI orchestration service. One API, multiple AI providers.

Topics

Resources

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages