One API to rule them all!
A universal gateway that connects to every major AI service in one place:
- β Gemini (Google) - Free
- β OpenAI (ChatGPT) - Paid
- β Claude (Anthropic) - Paid
- β Groq (Fast inference) - Free
- β Ollama (Local models) - Free
- β HuggingFace - Free
- β And more...
git clone https://github.com/NeXifiyAI/ai-gateway.git
cd ai-gateway
# Install dependencies
npm install
# Copy environment template
cp .env.example .envGEMINI_API_KEY=your_key_here
OPENAI_API_KEY=sk_test_xxxxx
ANTHROPIC_API_KEY=sk-ant-xxxxx
GROQ_API_KEY=gsk_xxxxx
OLLAMA_URL=http://localhost:11434
HF_API_KEY=hf_xxxxx
Option A: Docker (Recommended)
docker-compose -f docker/docker-compose.yml up -d
# Gateway: http://localhost:3000
# Open WebUI: http://localhost:3001Option B: Manual
npm run dev
# Gateway: http://localhost:3000npm run deploy
# Your gateway is now live! πfrom clients.ai_gateway_client import AIGatewayClient
# Local
client = AIGatewayClient('http://localhost:3000')
# Or Vercel
client = AIGatewayClient('https://your-gateway.vercel.app')
# Chat
response = client.chat('gemini', 'What is AI?')
print(response['message'])
# List models
models = client.list_models('gemini')
print(models['models'])
# Health check
health = client.health_check()
print(health['status'])const AIGatewayClient = require('./clients/AIGatewayClient');
const client = new AIGatewayClient('http://localhost:3000');
// Chat
const response = await client.chat('gemini', 'What is AI?');
console.log(response.message);
// Models
const models = await client.listModels('gemini');
console.log(models.models);
// Health
const health = await client.healthCheck();
console.log(health.status);# Chat
curl -X POST http://localhost:3000/api/chat \
-H "Content-Type: application/json" \
-d '{
"provider": "gemini",
"message": "What is AI?"
}'
# Models
curl http://localhost:3000/api/models?provider=gemini
# Health
curl http://localhost:3000/api/healthSend a message to any provider.
Request:
{
"provider": "gemini",
"message": "What is the meaning of life?",
"model": "gemini-1.5-pro",
"temperature": 0.7,
"maxTokens": 1024
}Response:
{
"provider": "gemini",
"model": "gemini-1.5-pro",
"message": "The meaning of life is subjective...",
"usage": {
"inputTokens": 5,
"outputTokens": 50
}
}Get available models for a provider.
Response:
{
"provider": "gemini",
"models": [
"gemini-1.5-pro",
"gemini-1.5-flash",
"gemini-1.0-pro"
]
}Check gateway health and provider status.
Response:
{
"status": "ok",
"timestamp": "2025-01-17T10:30:00Z",
"providers": [
{
"name": "Gemini",
"status": "configured"
},
{
"name": "OpenAI",
"status": "not-configured"
}
]
}| Provider | Model | Speed | Cost | Setup |
|---|---|---|---|---|
| Gemini | gemini-1.5-pro | β‘β‘β‘ | Free | Add API Key |
| OpenAI | gpt-4-turbo | β‘β‘ | Paid | Add API Key |
| Claude | claude-3-opus | β‘β‘β‘ | Paid | Add API Key |
| Groq | mixtral-8x7b | β‘β‘β‘ | Free | Add API Key |
| Ollama | mistral | β‘ | Free | Local |
| HuggingFace | Llama-2 | β‘β‘ | Free | Add API Key |
# Start all (Gateway + Ollama + Open WebUI)
docker-compose -f docker/docker-compose.yml up -d
# View logs
docker-compose -f docker/docker-compose.yml logs -f
# Stop all
docker-compose -f docker/docker-compose.yml down- Gateway: http://localhost:3000
- Open WebUI: http://localhost:3001
- Ollama API: http://localhost:11434
git add .
git commit -m "Initial commit: AI Gateway"
git push origin mainnpm run deployOr manually on vercel.com:
- Connect your GitHub repository
- Add environment variables
- Deploy!
https://your-project.vercel.app/api/chat
- β API keys stored in environment variables
- β CORS enabled (configurable)
- β No keys exposed in logs
- β Rate limiting recommended for production
import { useState } from 'react';
import AIGatewayClient from './clients/AIGatewayClient';
const client = new AIGatewayClient(process.env.REACT_APP_GATEWAY_URL);
export function ChatComponent() {
const [message, setMessage] = useState('');
const [response, setResponse] = useState('');
const handleSend = async () => {
const result = await client.chat('gemini', message);
setResponse(result.message);
};
return (
<div>
<input value={message} onChange={e => setMessage(e.target.value)} />
<button onClick={handleSend}>Send</button>
<p>{response}</p>
</div>
);
}from fastapi import FastAPI
from clients.ai_gateway_client import AIGatewayClient
app = FastAPI()
client = AIGatewayClient('https://your-gateway.vercel.app')
@app.post('/ask')
async def ask(question: str, provider: str = 'gemini'):
response = client.chat(provider, question)
return response# Install dependencies
npm install
# Run locally with hot reload
npm run dev
# Build
npm run build
# Deploy to production
npm run deployai-gateway/
βββ api/
β βββ gateway.js # Core routing logic
β βββ chat.js # Chat endpoint
β βββ models.js # Models endpoint
β βββ health.js # Health check
βββ clients/
β βββ ai_gateway_client.py # Python client
β βββ AIGatewayClient.js # JavaScript client
βββ docker/
β βββ docker-compose.yml # Local development
βββ vercel.json # Vercel config
βββ package.json # Dependencies
βββ .env.example # Environment template
βββ README.md # This file
Contributions welcome! Please:
- Fork the repository
- Create a feature branch
- Submit a pull request
MIT License - see LICENSE file
- π Documentation: See
/docs - π Issues: GitHub Issues
- π¬ Discord: [Community Server]
- π§ Email: support@nexifiyai.com
Made with β€οΈ by NeXifiyAI