Skip to main content

Multi-modal AI API Gateway - Unified interface for multiple AI providers

Project description

Obscura API Hub - FastAPI Backend

Multi-modal AI API Gateway with intelligent routing and provider management.

Features

  • 🔐 Token-based authentication
  • 🎯 Intelligent routing strategies (auto/cost/speed/quality/balanced)
  • 🔄 Automatic API key rotation
  • 📊 Usage tracking and quotas
  • 🚀 Multi-modal support (text, image, video, audio)
  • 🔌 OpenAI-compatible API
  • 💪 Provider health monitoring
  • ⚡ Streaming support

Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment:
cp .env.example .env
# Edit .env with your configuration
  1. Run the server:
# Development
python -m app.main

# Production
uvicorn app.main:app --host 0.0.0.0 --port 8000

API Endpoints

OpenAI-Compatible Endpoints

  • POST /v1/chat/completions - Chat completions with multimodal support
  • POST /v1/embeddings - Text embeddings
  • GET /v1/models - List available models
  • POST /v1/audio/transcriptions - Audio transcription (Whisper)
  • POST /v1/images/generations - Image generation (Lovable AI)
  • POST /v1/files - File upload to R2

Internal Endpoints

  • GET /health - Health check
  • POST /internal/models/refresh - Refresh model cache

Multimodal Support ⭐

Supports vision, video, and audio understanding through SiliconFlow:

# Vision understanding
{
    "model": "Qwen/Qwen2.5-VL-72B-Instruct",
    "messages": [{
        "role": "user",
        "content": [
            {"type": "image_url", "image_url": {"url": "...", "detail": "high"}},
            {"type": "text", "text": "描述这张图片"}
        ]
    }]
}

# Video understanding
{
    "model": "Qwen/Qwen3-Omni-30B-A3B-Instruct",
    "messages": [{
        "role": "user",
        "content": [
            {"type": "video_url", "video_url": {"url": "...", "max_frames": 16, "fps": 1}},
            {"type": "text", "text": "总结视频内容"}
        ]
    }]
}

# Audio understanding
{
    "model": "Qwen/Qwen3-Omni-30B-A3B-Instruct",
    "messages": [{
        "role": "user",
        "content": [
            {"type": "audio_url", "audio_url": {"url": "..."}},
            {"type": "text", "text": "转录这段音频"}
        ]
    }]
}

API Documentation

Once running, visit:

Project Structure

backend/
├── app/
│   ├── api/              # API endpoints
│   │   ├── v1/           # v1 endpoints (OpenAI-compatible)
│   │   └── internal/     # Internal endpoints
│   ├── core/             # Core functionality (auth, routing)
│   ├── db/               # Database operations
│   ├── models/           # Pydantic models
│   ├── providers/        # LLM provider implementations
│   ├── services/         # Business logic services
│   ├── utils/            # Utilities
│   └── main.py           # FastAPI app
├── tests/                # Tests
└── requirements.txt      # Dependencies

Testing

pytest tests/

Environment Variables

See .env.example for all configuration options.

Key Features

Intelligent Routing

  • auto: Balance health and priority
  • cost: Minimize cost
  • speed: Minimize latency
  • quality: Maximize quality
  • balanced: Balance all factors

Provider Health Monitoring

  • Automatic health tracking
  • Failure rate calculation
  • Unhealthy provider detection (>30% failure rate)

API Key Rotation

  • Round-robin rotation
  • Health-based selection
  • Automatic failover

Model Binding

  • Models can be bound to specific providers
  • Cross-provider fallback disabled for bound models
  • Automatic model discovery and caching

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

obscuraaihub-1.0.0.tar.gz (29.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

obscuraaihub-1.0.0-py3-none-any.whl (46.0 kB view details)

Uploaded Python 3

File details

Details for the file obscuraaihub-1.0.0.tar.gz.

File metadata

  • Download URL: obscuraaihub-1.0.0.tar.gz
  • Upload date:
  • Size: 29.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for obscuraaihub-1.0.0.tar.gz
Algorithm Hash digest
SHA256 8b05fca087873de5eae23f80edda3de066684d448dad4022c45bf7b681f79a83
MD5 7681c0bd3f332b45c05992aa83510731
BLAKE2b-256 dbc0a17bff25f6165adf944e0dc13b81ea6f4d37eb9688544ef5d13f4a14401f

See more details on using hashes here.

File details

Details for the file obscuraaihub-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: obscuraaihub-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 46.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for obscuraaihub-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0760effcc160d92c1e3608aee47f0d8f10e6e176db9d5ffe3794685ea3b6e7c7
MD5 15bad0ae65287cf43f2033da095cf1e7
BLAKE2b-256 2e253eb8f2f81531adc84093d94d7cfd43cfbf87ffebe57d6088323ca6182c3f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page