-
Notifications
You must be signed in to change notification settings - Fork 2
architecture provider abstraction
Note
👋 Hey there! Siyarix is a personal passion project built by a single developer that is growing and under active development. Some of the architectural components and features described on this page might currently be Planned, Work in Progress, or basic implementations. Stay tuned as it evolves! 🚀
Welcome to the Provider Abstraction Layer! This component is the beating heart of our AI infrastructure. It smoothly decouples all AI-dependent components from specific model backends, making our system resilient, flexible, and fully provider-agnostic.
Think of it as an intelligent traffic controller for your AI models. It effortlessly manages 26 different provider profiles with features like automatic failover, circuit breaking, exponential backoff, and token usage tracking. Plus, it brings everything together under a single, unified OpenAICompat adapter.
Note
Provider states are intelligently persisted as JSON files. This ensures your AI configuration and cooldown statuses carry over seamlessly across different sessions!
Here is a bird's-eye view of how the abstraction layer sits within the overall system:
┌──────────────────────────────────────────────────────┐
│ Consumer Layer │
│ (Planner, ChatSession, AutonomousExecutor, Swarm) │
└─────────────────────────┬────────────────────────────┘
│
▼
┌──────────────────────────────────────────────────────┐
│ ProviderManager │
│ │
│ • Provider selection (preference chain + scoring) │
│ • Failover orchestration │
│ • Circuit breaking (record_failure) │
│ • Rate limiting │
│ • DLP data redaction │
│ • Provider filtering by capability │
└──────┬───────────┬───────────┬───────────┬───────────┘
│ │ │ │
▼ ▼ ▼ ▼
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
│OpenAI │ │Ollama │ │LM Studio │ │llama.cpp │
│Compat │ │Utils │ │(OpenAI │ │(OpenAI │
│Adapter* │ │(local) │ │Compat) │ │Compat) │
└──────────┘ └──────────┘ └──────────┘ └──────────┘
│ │
▼ ▼
26 Provider Profiles (cloud, local, heuristic fallback)
Tip
* The OpenAICompat adapter (siyarix/chat/openai_compat.py) acts as a universal translator. It provides a standardized OpenAI-compatible API across all providers that support the OpenAI chat completions protocol!
Unlike traditional object-oriented systems that use heavy abstract base classes, we define providers using lightweight data profiles. This makes them incredibly fast to load and easy to configure.
You can find the core data models in the types module (siyarix/providers/types.py):
@dataclass
class ProviderProfile:
name: str
display_name: str
provider_type: str # "cloud" | "local" | "heuristic"
base_url: str
api_key_env: str | None # Which environment variable holds the key?
models: list[ModelInfo]
capabilities: set[str] # e.g., "chat", "embed", "function_calling", "vision"
priority: int # Position in the preference chain
rate_limit: int | None = None
timeout: int = 60@dataclass
class ModelInfo:
id: str
display_name: str
context_window: int
max_output_tokens: int
capabilities: set[str] # What can this model do?Need a provider with specific superpowers? Filtering is built right in:
# Grab providers with the exact capabilities you need:
vision_providers = pm.get_providers_by_capability("vision")
free_providers = pm.get_providers_by_capability("free")
local_providers = pm.get_providers_by_capability("local")
fn_call_providers = pm.get_providers_by_capability("function_calling")Our system is ready out-of-the-box to connect with an impressive array of AI backends.
These providers require authentication but offer the most powerful, cutting-edge models.
| Registry Name | SDK / API | Notable Models |
|---|---|---|
openai |
openai |
GPT-4o, GPT-4-turbo, GPT-3.5-turbo |
gemini |
google-generativeai |
Gemini 2.0 Flash, 1.5 Pro |
anthropic |
anthropic |
Claude 3.5 Sonnet, Claude 3 Opus |
groq |
groq |
Llama 3 70B, Mixtral 8x7B |
together |
together |
Mixtral, DeepSeek, Llama variants |
openrouter |
openai |
Multi-model router |
deepseek |
openai |
DeepSeek-V2, DeepSeek-Coder |
xai |
openai |
Grok |
mistral |
mistralai |
Mistral Large, Mistral Small |
perplexity |
openai |
Sonar, Sonar-Pro |
cerebras |
openai |
Fast inference models |
fireworks |
openai |
Open model serving |
zai |
openai |
Z.A.I. models |
minimax |
openai |
MiniMax models |
moonshot |
openai |
Moonshot / Kimi |
nvidia |
openai |
NVIDIA Nemotron |
huggingface |
huggingface-hub |
Hugging Face Inference API |
azure |
openai |
Azure OpenAI (personal, managed AD) |
opencode_zen |
openai |
OpenCode Zen backend |
Run AI completely offline, free, and secure directly on your own hardware!
| Registry Name | Default Endpoint | Notes |
|---|---|---|
ollama |
http://localhost:11434 |
The easiest way to pull and run open-weight models |
lmstudio |
http://localhost:1234 |
Awesome GUI + local API server |
llamacpp |
http://localhost:8080 |
Highly efficient CPU/GPU inference |
vllm |
Configurable | Built for high-throughput GPU serving |
localai |
http://localhost:8080 |
A seamless drop-in OpenAI replacement |
When all else fails, we have reliable, non-AI fallbacks.
| Name | Description |
|---|---|
registry |
RegistryPlanner — A 100% rule-based system, always available and offline-safe. |
Dealing with dozens of different API specifications is a headache. That's why we created the OpenAICompat adapter (siyarix/chat/openai_compat.py). It acts as a universal bridge for over 14+ providers.
By standardizing around the OpenAI chat completions protocol, you write your code once, and it automatically supports:
- 💬 Chat completions & Streaming responses
- 🧠 Embedding generation
- ⚙️ Tool and function calling
- 📋 Structured output (JSON mode)
# Look how easy it is to swap providers!
adapter = OpenAICompat(provider="openai", api_key=...)
adapter = OpenAICompat(provider="groq", api_key=...)
adapter = OpenAICompat(provider="deepseek", api_key=...)The ProviderManager (siyarix/providers/manager.py) is the smart coordinator of the entire system.
How does it decide which AI to use? It evaluates several factors dynamically:
-
User Preference: Starts with your
model_providerconfig. -
Key Availability: Checks the
CredentialStorefor valid API keys. - Health Status: Performs quick connectivity tests.
- Task Matching: Ensures the provider supports the requested feature (like vision or function calling).
- Cooldowns: Actively avoids providers that recently failed.
- Historical Reliability: Deprioritizes providers with high error rates.
When set to model_provider = "auto", the system acts autonomously, marching down a prioritized list until it finds a working model:
Gemini → OpenAI → Anthropic → Groq → Together → OpenRouter → DeepSeek → xAI → Mistral → Perplexity → Cerebras → Fireworks → ZAI → MiniMax → Moonshot → NVIDIA → HuggingFace → Azure → OpenCode Zen → Ollama → LM Studio → llama.cpp → vLLM → LocalAI → Registry (Heuristic)
Important
Our architecture guarantees robust failovers. If an AI provider goes down, your app doesn't crash—it seamlessly routes to the next best option!
Request → Provider A (Preferred)
│
├── ✅ Success → Return result, record success
│
└── ❌ Failure → Trigger record_failure()
│
▼
ProviderStateManager enforces cooldown
│
▼
Provider B (Next in chain)
│
├── ✅ Success → Return result
│
└── ❌ Failure → Continue chain
│
▼
Registry (Heuristic fallback)
Want to know how your providers are performing?
stats = provider_manager.stats()
# You instantly get detailed usage stats, error rates, and current statuses!To protect your system from hanging endlessly on broken APIs, we use a Circuit Breaker pattern via ProviderManager.record_failure().
| Parameter | Default | What it means |
|---|---|---|
| Failure threshold | 3 | How many consecutive errors trigger a circuit "trip" (opening the circuit). |
| Recovery timeout | 60s | Time to wait before cautiously trying the provider again (half-open). |
| Cooldown duration | 300s | Total time a provider is "benched" after failing hard. |
state = provider_manager.record_failure("openai") # Trips to OPEN after 3 strikes
state = provider_manager.record_success("gemini") # Restores trust, moving back to CLOSEDYour system's memory isn't wiped when you restart. The ProviderStateManager saves the exact state of your providers into a simple JSON file (provider_state.json).
@dataclass
class ProviderState:
provider_name: str
circuit_state: str # CLOSED | OPEN | HALF_OPEN
failure_count: int
last_failure: datetime | None
cooldown_until: datetime | None
rate_limited_until: datetime | None
total_requests: int
total_tokens: int
total_cost: floatTip
Because this is saved to disk, if a provider hits a rate limit right before you close your app, it will still correctly skip that provider when you reboot!
Keep your AI costs under control! The UsageTracker monitors every single token and penny.
| Metric | How it's tracked |
|---|---|
| Prompt tokens | Per Request |
| Completion tokens | Per Response |
| Total tokens | Request + Response |
| Estimated cost | Based on the provider's specific rate card |
| Request count | Per Session |
| Latency | Per Request |
tracker = UsageTracker()
tracker.record("openai", prompt_tokens=150, completion_tokens=450, latency=2.3)
summary = tracker.get_summary("openai")
# Instantly see exactly what you spent:
# UsageSummary(total_tokens=600, total_cost=0.009, avg_latency=2.3, request_count=1)When an API blinks with a temporary error (like a 429 Rate Limit or 503 Server Error), we don't just hammer it. We respectfully back off using jittered exponential delays:
# Formula for our smart delays
backoff = min(2 ** attempt + random.uniform(0, JITTER), MAX_DELAY)| Attempt | Delay Range | Max Delay |
|---|---|---|
| 1st Try | 1.0 – 2.0s | 30s |
| 2nd Try | 2.0 – 3.0s | 30s |
| 3rd Try | 4.0 – 5.0s | 30s |
| 4th Try | 8.0 – 9.0s | 30s |
| 5th+ Try | 16.0 – 17.0s | 30s |
Running models locally? siyarix/providers/ollama_utils.py makes it a breeze with dedicated helpers for Ollama:
- 🔍 Auto-Discovery: Automatically lists your downloaded models.
- ⬇️ Smart Pulling: Downloads missing models with live progress tracking.
- ❤️ Health Checks: Monitors your local endpoint's vitals.
- 💻 Hardware Awareness: Intelligently selects models that fit your specific GPU/CPU constraints.
We take your data seriously. Before any information leaves your machine and hits a cloud provider, our DLPEngine (siyarix/dlp.py) scrubs it clean.
Warning
Never disable the DLPEngine in a production cloud environment!
| Data Type | Sent to Cloud Provider | Behavior for Local Models |
|---|---|---|
| IP addresses | Masked as 10.x.x.x
|
Sent safely unmasked |
| Credentials | [REDACTED] |
Permanently redacted |
| API keys | [REDACTED] |
Permanently redacted |
| Internal hostnames | Masked as example.com
|
Sent safely unmasked |
| JWTs / tokens | [REDACTED] |
Permanently redacted |
AI companies change their model names all the time. The ModelAliases system (siyarix/model_aliases.py) abstracts this away so your code never breaks when a new version drops!
| Your Code Asks For | We Actually Route To |
|---|---|
gpt-4 |
gpt-4-turbo or gpt-4o (automatically uses the best available) |
claude-3 |
claude-3-opus or claude-3-sonnet
|
gemini-pro |
gemini-1.5-pro or gemini-2.0-flash
|
llama-3 |
llama-3-70b or llama-3-8b
|
mixtral |
mixtral-8x7b or mixtral-8x22b
|
Here is how all these incredible features tie together:
┌────────────────────────┐
│ Consumer Layer │
│ (Planner, Chat, etc.) │
└────────┬───────────────┘
│
▼
┌────────────────────────┐
│ ProviderManager │
│ │
│ ┌──────────────────┐ │
│ │ ⛓️ Pref. Chain │ │
│ │ + Failover │ │
│ └──────────────────┘ │
│ ┌──────────────────┐ │
│ │ ⚡ Circuit Break │ │
│ │ (record_failure)│ │
│ └──────────────────┘ │
│ ┌──────────────────┐ │
│ │ ⏱️ Exp. Backoff │ │
│ └──────────────────┘ │
│ ┌──────────────────┐ │
│ │ 🛡️ DLP Redaction │ │
│ └──────────────────┘ │
│ ┌──────────────────┐ │
│ │ 🎯 Capability │ │
│ │ Filtering │ │
│ └──────────────────┘ │
└────────┬───────────────┘
│
┌─────────────┼─────────────┐
▼ ▼ ▼
┌──────────────┐ ┌──────────────┐ ┌──────────────┐
│ OpenAICompat │ │ ProviderState│ │ Ollama │
│ Adapter │ │ Manager │ │ Utils │
│ (14+ APIs) │ │ (JSON File) │ │ (Local AI) │
└──────────────┘ └──────────────┘ └──────────────┘
│
▼
┌────────────────────────┐
│ UsageTracker │
│ (Tokens + Cost Per │
│ Provider) │
└────────────────────────┘
Note
👋 Welcome to Siyarix! This is a personal passion project built by a single developer. It's currently under active development and growing fast. Expect rough edges, but lots of love! ❤️
Welcome to the Siyarix Documentation Map! This page serves as your master compass for navigating the extensive documentation we have built for the platform.
Whether you are a brand new user, a seasoned security operator, or a developer looking to contribute to the core engine, you can find exactly what you need here.
Not sure where to start? Pick the path that best describes you:
Just getting started? We highly recommend following these guides in order:
- Installation Guide — Get Siyarix running on your machine.
- Onboarding Wizard — Let our interactive wizard help you set up your API keys and environment.
- Setup & Configuration — A deeper dive into customizing your setup.
- Your First Run — A gentle walkthrough of your very first Siyarix command.
Ready to put Siyarix to work? Dive into our operational guides:
- Interactive Chat (REPL) — Learn how to use the powerful interactive terminal.
- Security Workflows — Best practices for recon, vulnerability assessment, and incident response.
- Cloud & IaC Scanning — How to secure your cloud environments and infrastructure code.
- Compliance Frameworks — Map your scans to SOC 2, HIPAA, ISO 27001, and more.
Looking under the hood or wanting to write some code? Start here:
- Contribution Guide — Our workflow, standards, and how you can help!
- Codebase Overview — A comprehensive map of our 82+ source modules.
- Testing Standards — How we ensure reliability with pytest and CI/CD.
- Module Architecture — Component design and responsibilities.
If you prefer to browse the raw structure, here is a complete layout of the docs/ folder:
docs/
├── 🚀 getting-started/ # Installation, onboarding, and configuration
│ ├── installation.md # Multi-platform install (pip, brew, winget, docker)
│ ├── onboarding.md # The interactive 11-step setup wizard
│ ├── setup.md # Managing API keys, credentials, and settings
│ ├── first-run.md # A walkthrough of your first session
│ ├── configuration.md # A deep-dive into advanced settings
│ └── troubleshooting.md # Common issues and how to fix them instantly
│
├── 📖 user/ # Daily operations and workflows
│ ├── cli-commands.md # Reference for 50+ CLI commands across 12 groups
│ ├── interactive-chat.md # Mastering the AI REPL and 54+ slash commands
│ ├── security-workflows.md # Recon, vulnerability assessment, incident response
│ ├── cloud-scanning.md # Multi-cloud security scanning (under development)
│ ├── compliance.md # Framework mapping (SOC 2, NIST, GDPR, PCI-DSS)
│ ├── threat-intelligence.md# Integrations with OTX, NVD, and MITRE ATT&CK
│ ├── playbooks.md # Building automated YAML-based IR playbooks
│ ├── workflow-files.md # DAG workflow reference (programmatic API)
│ ├── reporting.md # Multi-format report generation
│ ├── offline-registry.md # Running without AI (Offline/Registry execution mode)
│ └── ai-workflows.md # Advanced AI-driven autonomous operations
│
├── 💻 developer/ # Building, testing, and extending Siyarix
│ ├── codebase-overview.md # Full module structure mapping
│ ├── contribution-guide.md # How to submit PRs and our coding standards
│ ├── module-architecture.md# Component design and responsibilities
│ ├── testing.md # Writing tests (pytest), coverage, and CI/CD
│ └── building.md # Packaging, distribution, and Docker builds
│
├── 🏗️ architecture/ # System design and core internals
│ ├── overview.md # High-level data flow and layered orchestration
│ ├── ai-agent-pipeline.md # The AgentCore reasoning and execution pipeline
│ ├── provider-abstraction.md# How we unify 26 different AI providers
│ ├── execution-engine.md # Plan-based step orchestration
│ ├── memory-and-state.md # Knowledge graph, session persistence, and learning
│ ├── security-model.md # The Permission Gate, DLP, audit logging, and OPSEC
│ └── intent-routing.md # Semantic intent classification and routing
│
├── 🧠 ai/ # Deep dive into the AI provider & agent systems
│ ├── routing.md # Managing 26 providers, failovers, and circuit breakers
│ ├── persona-system.md # Overview of our 10 security personas
│ ├── agent-reasoning.md # The Observe-Reason-Act loop and tool call repair
│ ├── tool-execution.md # The tool registry, capability graph, and parsers
│ ├── ensemble.md # Parallel LLM voting strategies
│ ├── multi-wave.md # Iterative goal execution with context carry-over
│ ├── prompt-architecture.md# System prompt design and management
│ └── safety.md # Our rigorous 8-layer hallucination mitigation system
│
├── 🛡️ security/ # Safety, ethics, and threat models
│ ├── reporting.md # How to safely report vulnerabilities to us
│ ├── threat-model.md # System threat model and our mitigations
│ ├── operational-security.md# TOR routing, stealth modes, and OPSEC controls
│ ├── ethical-policy.md # Mandatory rules of engagement for all users
│ └── abuse-prevention.md # How we prevent misuse of the AI engine
│
└── ⚖️ legal/ # Licensing and governance
├── agpl-guide.md # A plain-English overview of the AGPL-3.0-or-later license
├── why-agpl.md # The philosophy behind our license choice
├── trademark-policy.md # Branding and trademark guidelines
├── responsible-ai.md # Our framework for ethical AI usage
├── disclaimer.md # Important legal disclaimers
└── plugin-exception.md # The license exception for building custom plugins
As you read through the documentation, you might encounter some specific terms. Here is a quick cheat sheet:
| Term | What It Means |
|---|---|
| Provider | The backend AI engine powering Siyarix (e.g., OpenAI, Anthropic, Ollama). |
| Tool | A traditional security executable installed on your system (e.g., nmap, nuclei). |
| Plan | A step-by-step sequence of tool commands intelligently generated by the AI. |
| Workflow | A hardcoded, predefined execution path (usually defined in YAML/JSON) that doesn't require AI generation. |
| Persona | A specialized behavioral profile given to the AI (e.g., instructing it to act specifically as a "Network Recon Specialist"). |
| Knowledge Graph | Siyarix's internal memory where it stores findings (like IP addresses, open ports) to contextually inform future steps. |
Need help finding something specific? Feel free to use the search bar at the top of the documentation site, or open a discussion on our GitHub!