Architecture
LLM Gateway Core uses a provider abstraction layer to support multiple LLM backends through a unified interface. This architecture enables:- Seamless switching between different LLM providers
- Consistent API regardless of the underlying provider
- Easy addition of new providers
- Provider-agnostic routing and middleware
Provider Base Class
All providers inherit from theLLMProvider abstract base class, which defines the contract every provider must implement.
app/providers/base.py
Required Methods
chat() - Execute chat completions
chat() - Execute chat completions
Signature:
async def chat(self, request: ChatRequest) -> ChatResponse- Purpose: Process a chat completion request and return a response
- Input:
ChatRequestcontaining messages, model, and parameters - Output:
ChatResponsewith generated content and usage stats - Async: Must be async to support concurrent requests
name - Provider identifier
name - Provider identifier
Signature:
@property def name(self) -> str- Purpose: Return a unique identifier for the provider
- Examples:
"gemini","ollama" - Usage: Used for routing and response metadata
Available Providers
LLM Gateway Core includes built-in support for the following providers:Google Gemini
Cloud-based Google Gemini API integration with gemini-2.5-flash model
Ollama
Local Ollama integration for privacy-focused deployments
Provider Registry
Providers are registered in theRouter class, which manages provider instances and handles request routing.
app/core/router.py
Request/Response Schema
ChatRequest
ChatResponse
Usage Stats
All providers must return responses in this standardized format, regardless of their native API structure.
Next Steps
Gemini Provider
Learn about Google Gemini integration
Ollama Provider
Set up local Ollama deployment
Custom Providers
Implement your own provider
Router Configuration
Configure request routing