fastapi-gateway-pattern
CommunityBuild an OpenAI-compatible FastAPI LLM gateway.
Software Engineering#fastapi#rate limiting#sse streaming#openai-compatible api#llm gateway#api key auth#quota accounting
Authorsaintgo7
Version1.0.0
Installs0
System Documentation
What problem does it solve?
This Skill solves the problem of exposing multiple OpenAI-compatible LLM backends behind a single stable endpoint while enforcing authentication, quotas, streaming, and usage logging without entangling route code with infrastructure concerns.
Core Features & Use Cases
- OpenAI-compatible gateway front-end: Provide /v1/chat/completions, /v1/models, health, metrics, and admin endpoints while routing requests to upstream backends (vLLM/TGI/llama.cpp/sglang).
- Five-layer separation: Split responsibilities into Auth middleware, RateLimit middleware, Logging middleware, Routes layer, and Services layer to keep the system extensible and safe.
- Quota enforcement with observability: Combine RPM (slowapi), concurrent in-flight limits (per-user Semaphore), and daily token caps (DB-based aggregation) plus structured usage inserts after response completion.
- Streaming SSE pass-through: Proxy upstream SSE responses to clients while intercepting usage chunks to update accounting without breaking client SDK event boundaries.
- Production-ready DB pool sizing: Apply a verified SQLAlchemy async pool configuration to survive ~50 concurrent connections with fewer QueuePool timeouts.
Quick Start
Use the fastapi-gateway-pattern skill to scaffold a FastAPI gateway project by following the provided SKILL.md structure and then start implementing the auth, quota, streaming proxy, and usage logging layers.
Dependency Matrix
Required Modules
None requiredComponents
Standard package💻 Claude Code Installation
Recommended: Let Claude install automatically. Simply copy and paste the text below to Claude Code.
Please help me install this Skill: Name: fastapi-gateway-pattern Download link: https://github.com/saintgo7/claude-skills/archive/main.zip#fastapi-gateway-pattern Please download this .zip file, extract it, and install it in the .claude/skills/ directory.
Agent Skills Search Helper
Install a tiny helper to your Agent, search and equip skill from 471,000+ vetted skills library on demand.