Omniference
A flexible, multi-protocol inference engine that provides a unified interface for interacting with various AI model providers such as Ollama, OpenAI, and others through a common API.
Features
- Multi-provider support: Ollama, OpenAI, and extensible architecture for more providers
- Streaming support: Real-time streaming responses from AI models
- OpenAI-compatible API: Drop-in replacement for OpenAI's API
- Multiple interfaces: HTTP server, Discord bot, CLI, library usage
- Embeddable: Can be integrated into existing Axum applications
- Async/await: Built on Tokio for high-performance async operations
- Type-safe: Strong typing throughout the library
Architecture
The library is organized in layers:
- Core Layer: Router, adapters, and types (pure inference logic)
- Service Layer: Provider management and model resolution
- Interface Layer: HTTP APIs, Discord bot, CLI, etc.
- Application Layer: Full server or embeddable components
Quick Start
Installation
Add to your Cargo.toml:
[]
= "0.1.0"
Usage Examples
1. Library Usage
Use Omniference as a library in any async context:
use ;
use Arc;
async
2. Standalone HTTP Server
Run as a standalone HTTP server with OpenAI-compatible API:
use ;
use Arc;
async
3. Embedded in Existing Axum Application
Integrate into an existing Axum application:
use ;
use ;
use Arc;
async
4. Discord Bot Integration
Create a Discord bot with AI capabilities
[]
= { = "0.1.0" }
use ;
use Arc;
// Set up engine in your Discord bot handler
let mut engine = new;
engine.register_provider.await?;
// Use in message handlers
let response = engine.chat_complete.await?;
Examples
The crate includes several examples:
cargo run --example library_usage- Basic library usagecargo run --example embedded_axum- Embed in existing Axum appcargo run --example standalone_server- Run as standalone servercargo run --example discord_bot- Discord bot integration
API Endpoints
When running as a server, Omniference provides:
POST /api/openai/v1/responses- OpenAI Responses API (new, OpenAI-only)GET /api/openai/v1/models- List available modelsPOST /api/openai-compatible/v1/chat/completions- OpenAI-compatible Chat CompletionsGET /api/openai-compatible/v1/models- OpenAI-compatible models endpoint
Configuration
Examples via .env
Examples read configuration from environment variables. Copy .env.example to .env and set values as needed:
cp .env.example .env
# then edit .env
Key variables:
OLLAMA_BASE_URL(defaulthttp://localhost:11434)OPENAI_BASE_URL(defaulthttps://api.openai.com)OPENAI_API_KEY(required for OpenAI-compatible examples)DISCORD_TOKEN(required for the Discord example)SERVER_ADDRandEMBEDDED_SERVER_ADDRto change example ports
Provider Configuration
Configure providers with custom endpoints and settings:
ProviderConfig
Model Resolution
Models are auto-discovered from providers and can be referenced using:
- Provider-prefixed format:
ollama/llama3.2 - Direct model names:
llama3.2 - Custom aliases configured by your application
Building and Testing
# Build the library
# Run tests
# Run examples
# Run with Discord support
Features
default: Core functionality without optional dependenciesdiscord: Enables Discord bot integration with Serenity
License
MIT - see LICENSE for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Roadmap
- Support for more providers (OpenAI, Anthropic, etc.)
- Additional protocol skins (Anthropic Messages API, etc.)
- Advanced configuration management
- Performance optimizations and caching
- Monitoring and metrics
- Load balancing and failover