Skip to main content

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:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

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

Metadata

Release files for obscuraaihub 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for obscuraaihub 1.0.0
File Size Uploaded Provenance Actions
obscuraaihub-1.0.0.tar.gz 29.3 kB Without provenance Details for obscuraaihub-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for obscuraaihub 1.0.0
File Interpreter ABI Platform Actions
obscuraaihub-1.0.0-py3-none-any.whl Python 3 none any Details for obscuraaihub-1.0.0-py3-none-any.whl

Total release size: 75.3 kB

Release files / obscuraaihub-1.0.0.tar.gz

Download URL obscuraaihub-1.0.0.tar.gz
Size 29.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8b05fca087873de5eae23f80edda3de066684d448dad4022c45bf7b681f79a83
BLAKE2b-256 checksum
How to use checksums
dbc0a17bff25f6165adf944e0dc13b81ea6f4d37eb9688544ef5d13f4a14401f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Release files / obscuraaihub-1.0.0-py3-none-any.whl

Download URL obscuraaihub-1.0.0-py3-none-any.whl
Size 46.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0760effcc160d92c1e3608aee47f0d8f10e6e176db9d5ffe3794685ea3b6e7c7
BLAKE2b-256 checksum
How to use checksums
2e253eb8f2f81531adc84093d94d7cfd43cfbf87ffebe57d6088323ca6182c3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.14

Security for obscuraaihub 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page