ghostrouter
English · 中文 · 日本語 · 한국어 · Русский · Deutsch
The LLM router that learns. Intelligent routing across 10+ providers, with fallback, circuit breakers, budget tracking, and post-model redaction.
Why
Every project hardcodes model names and API clients. When a model is slow, rate-limited, or refuses a request, the call just fails. ghostrouter routes each call to the best available model automatically — with circuit breakers, fallback chains, and post-model redaction baked in.
Install
pip install ghostrouter
Quick Start
import asyncio
from ghostrouter.config import initialize_controlcore
from ghostrouter.adapters.executor import execute_call
from ghostrouter.schemas import ControlCoreCall, Caller, Intent, Target
# Initialize registries (reads env vars for API keys)
config, model_registry, adapter_registry = initialize_controlcore()
# Build a call
call = ControlCoreCall(
caller=Caller(handle="my-app", account_id="00000000-0000-0000-0000-000000000000"),
intent=Intent(**{"class": "lookup"}), # `class` is aliased; use dict unpacking
target=Target(type="model", alias="claude"),
prompt="What is the capital of France?",
)
# Execute with automatic fallback
result, trace = asyncio.run(execute_call(call, model_registry, adapter_registry))
print(result.answer)
Or boot as a daemon and call over HTTP:
ghostrouter serve # binds to localhost:8265
ghostrouter run claude "Explain recursion"
ghostrouter result <job_id> --poll
Architecture
call → bouncer → eligibility filter → routing → adapter → redaction → result
↓
circuit breaker
↓
fallback chain
- Routing — scores eligible models by trust tier, cost, and latency history
- Eligibility — filters models by intent, verbosity, and determinism requirements
- Fallback — tries models in order; switches on timeout, error, refusal, or rate limit
- Adapter — thin shim per provider; no shared state between providers
- Redaction — applied to model output (not the prompt); strips leaked secrets, emails, phone numbers
Providers
| Provider | Models |
|---|---|
| OpenAI | GPT-4, GPT-4o, o1, o1-mini |
| Anthropic | Claude Sonnet, Opus, Haiku |
| Gemini 1.5 Pro/Flash, Gemini 2.0 | |
| xAI | Grok, Grok-2 |
| Mistral | Mistral Large/Medium/Small, Codestral |
| Groq | Llama-70B, Llama-8B, Mixtral, Gemma |
| Together | Llama-405B, Qwen-72B, DeepSeek-V3 |
| DeepSeek | DeepSeek Chat, Coder, Reasoner |
| Perplexity | Sonar (search-augmented) |
| Ollama | Any local model |
Set the relevant *_API_KEY environment variables to enable each provider.
Key Features
- Circuit breakers — automatically open on repeated failures, recover with half-open probing
- Trust tiers — models tagged with trust levels; calls can require a minimum tier
- Post-model redaction — output is scanned and sanitized before returning to caller
- Execution traces — every call records which models were tried, timings, and outcomes
- Structured schemas — Pydantic v2 throughout; strict validation at every boundary
- Async-native — built on httpx + asyncio; runs in Starlette for low overhead
Spine Integration (optional)
ghostrouter supports maelspine for zero-import access to registries across a larger application:
from ghostrouter.boot import boot
core = boot() # idempotent singleton
# Any module, anywhere:
from spine import Core
registry = Core.instance().get("model_registry")
HTTP API
| Method | Path | Description |
|---|---|---|
| POST | /call |
Submit a call |
| GET | /result/{job_id} |
Poll for result |
| GET | /health |
Health + job stats |
| GET | /jobs |
List recent jobs |
Part of the GhostLogic Stack
maelspine — frozen capability registry
ghostrouter — LLM orchestration gateway ← you are here
ghostserver — evidence server (Blackbox)
License
Apache-2.0 — Copyright 2026 Adam Thomas / GhostLogic LLC
Metadata
Release files for ghostrouter 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ghostrouter-0.2.0.tar.gz | 112.5 kB | Without provenance | Details for ghostrouter-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ghostrouter-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for ghostrouter-0.2.0-py3-none-any.whl |
Total release size: 244.3 kB
Release files / ghostrouter-0.2.0.tar.gz
| Download URL | ghostrouter-0.2.0.tar.gz |
|---|---|
| Size | 112.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
47b27ab40755279954d039827ca6c7adb10f1325669aaa4e5743bbcb6c9d857b
|
|
BLAKE2b-256 checksum How to use checksums |
b24410a0924cbc15b7b2c559f85c80f81c999beacca905ca50936dcd96dcd24a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / ghostrouter-0.2.0-py3-none-any.whl
| Download URL | ghostrouter-0.2.0-py3-none-any.whl |
|---|---|
| Size | 131.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
857cd2b7fd40e65b73991d70c846e602f572bde78454d33ef91045740df933ee
|
|
BLAKE2b-256 checksum How to use checksums |
b31b63dd3a2bb6b601b1cb45c813b1c1e228fb2bb2923cd99948dd02ccdad5fa
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for ghostrouter 0.2.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.