Skip to content
Armin RAD edited this page Dec 16, 2025 · 7 revisions

Gatewayz Backend Wiki

Universal AI Gateway - Complete Documentation Hub

FastAPI Python Version

Production-ready AI gateway providing unified access to 100+ AI models across 17+ providers with enterprise security, credit management, and comprehensive monitoring.


Quick Navigation

Section Description
Getting Started New to the project? Start here
Features Feature documentation and guides
Deployment Deploy to production platforms
Monitoring Track errors and performance
Security Security and compliance
Integrations AI provider integrations
Development Developer workflows
API Reference Complete API documentation

Getting Started

New developers start here:

Document Description
Quick Start Get running in 15 minutes
Complete Setup Guide Full development environment setup
Environment Setup Configure environment variables
Architecture System architecture overview
Project Structure Codebase organization

First-Time Setup

# 1. Clone and navigate
git clone <repo-url>
cd gatewayz-backend

# 2. Install dependencies
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

# 3. Configure environment
cp .env.example .env
# Edit .env with your keys

# 4. Run server
python src/main.py

# 5. Test
curl http://localhost:8000/health

Core Features

API & Inference

Feature Documentation
Chat Completions OpenAI-compatible /v1/chat/completions endpoint
Messages API Anthropic-compatible Claude API
Image Generation AI-powered image creation
Model Catalog Browse 100+ models across providers
Model Health Real-time model availability tracking
Model Sync Automated catalog synchronization

User Management

Feature Documentation
Authentication Privy integration + custom auth
API Keys Encrypted key management with scopes
User Profiles Account management and settings
Activity Logging Comprehensive activity tracking
Audit Logs Security event logging
Roles & Permissions RBAC implementation

Billing & Credits

Feature Documentation
Pricing System Token-based pricing across models
Credit Management Real-time credit tracking and deduction
Stripe Integration Payment processing and subscriptions
Subscription Plans Tiered subscription management
Free Trials 3-day trial with $10 credits
Coupons Discount codes and promotions
Referral System User referral rewards

Performance & Reliability

Feature Documentation
Rate Limiting Redis-backed rate limiting
Caching Response and model catalog caching
Failover Automatic provider failover
Connection Pooling Optimized database connections
Request Prioritization Priority queue for critical requests

Advanced Features

Feature Documentation
Chat History Persistent conversation management
Analytics Usage analytics with PostHog
Feature Flags A/B testing with Statsig
Notifications Email notifications via Resend
Webhooks Stripe webhook handling

Deployment

Platform-Specific Guides

Platform Quick Start Detailed Guide
Railway Railway Quick Start Railway Setup
Vercel Vercel Quick Start Vercel Deployment
Docker Docker Quick Start Docker Guide

Deployment Topics

Topic Documentation
Auto-Deployment Setup automated deployments
Staging Environment Configure staging
Database Migrations Supabase Migrations CI
GitHub Secrets Configure CI/CD secrets
Environment Config Environment differentiation

Monitoring & Observability

Error Tracking

Tool Documentation
Sentry Error monitoring setup
PostHog Alternative error tracking
Audit Logs Security event logging

Performance

Topic Documentation
Metrics Prometheus metrics
Performance Monitoring Track and optimize performance
Health Checks System health monitoring
OpenTelemetry Distributed tracing

Dashboards

Dashboard Documentation
Grafana Setup Grafana dashboards
Monitoring System Complete Monitoring

Security

Topic Documentation
API Key Security Encryption, rotation, scopes
Secrets Management Managing sensitive data
Staging Security Secure staging environment
Incident Response Handle security incidents
Database Security Secure database access

Provider Integrations

Supported Providers (17+)

Provider Type Documentation
OpenRouter Multi-model gateway Primary provider
Google Vertex AI Enterprise AI Vertex Setup
Alibaba Cloud Chinese market Alibaba Integration
Cerebras Fast inference Native integration
DeepInfra Open models Native integration
Fireworks AI Optimized inference Native integration
Groq Ultra-fast LLMs Native integration
HuggingFace Model hub HF Integration
Together AI Open source models Native integration
Featherless Cost-effective Native integration
Chutes Specialized provider Native integration
+6 more Various See Integration Guide

Integration Guides

Topic Documentation
Add New Provider Integration guide
OneRouter OneRouter setup
Novita SDK Novita integration
Frontend Integration Connect frontend

Development

Workflows

Topic Documentation
Pre-Push Checklist Check before pushing
Testing Locally Test GitHub Actions
Live API Testing Test against live APIs
Failover Testing Test failover scenarios
Migration Sync Database migrations

Testing

Topic Documentation
Test Suite Running tests
Database Testing Test database
API Testing Apidog runner setup
OpenRouter Testing Automated validation

API Reference

Resource Documentation
Complete API Docs API Reference
OpenAPI Spec Access at /docs endpoint
Chat API Chat completions
Images API Image generation
Admin API Admin operations

Advanced Topics

Architecture

Topic Documentation
System Architecture Architecture
Database Schema Database design
Service Layer Business logic organization
Provider Abstraction Multi-provider pattern

Automation

Topic Documentation
Auto-Merge PRs Auto-merge setup
Automated Testing CI/CD testing
Model Sync Automated catalog sync

Troubleshooting

Topic Documentation
Common Issues Troubleshooting
Error Fixes Recent fixes
Auth Timeouts Fix auth issues
Prometheus Fixes Monitoring fixes

Quick Reference

Key Statistics

  • Total Features: 25+ major features
  • Supported Providers: 17+ AI providers
  • API Endpoints: 50+ endpoints
  • Available Models: 100+ models
  • Test Coverage: 85%+
  • Response Time: <100ms avg

Technology Stack

  • Framework: FastAPI 0.104.1
  • Database: Supabase (PostgreSQL)
  • Cache: Redis 5.0.1
  • Payments: Stripe 13.0.1
  • Email: Resend 0.8.0
  • Analytics: PostHog, Statsig
  • Monitoring: Sentry, Prometheus

External Links


Documentation Standards

When contributing documentation:

  • Use clear, concise language
  • Include code examples
  • Add diagrams for complex flows
  • Keep token usage efficient
  • Cross-reference related pages
  • Update this index when adding pages

Search Tips

I want to... Go to...
Set up my dev environment Complete Setup Guide
Deploy to production Railway Quick Start
Track errors Error Monitoring
Add a new provider Integration Guide
Understand pricing Pricing System
Secure my API Security
Run tests locally Testing Workflows
Fix a bug Troubleshooting

Last Updated: December 2024 Maintained By: Gatewayz Development Team Questions? Check Troubleshooting or open an issue

Clone this wiki locally