Skip to main content

ghostcore

LLM orchestration gateway with intelligent routing, fallback, and 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. ghostcore routes each call to the best available model automatically — with circuit breakers, fallback chains, and post-model redaction baked in.

Install

pip install ghostcore

Quick Start

from ControlCore.config import initialize_controlcore
from ControlCore.adapters.executor import execute_call
from ControlCore.schemas import ControlCoreCall, CallerIdentity, CallIntent, CallTarget

# Initialize registries (reads env vars for API keys)
config, model_registry, adapter_registry = initialize_controlcore()

# Build a call
call = ControlCoreCall(
    caller=CallerIdentity(handle="my-app", account_id="00000000-0000-0000-0000-000000000000"),
    intent=CallIntent(cls="lookup"),
    target=CallTarget(type="model", alias="claude"),
    prompt="What is the capital of France?",
)

# Execute with automatic fallback
import asyncio
result, trace = asyncio.run(execute_call(call, model_registry, adapter_registry))
print(result.answer)

Or boot as a daemon and call over HTTP:

ghostcore serve            # binds to localhost:8265
ghostcore run claude "Explain recursion"
ghostcore result <job_id> --poll

Architecture

call → bouncer → eligibility filter → routing → adapter → redaction → result
                                          ↓
                                   circuit breaker
                                          ↓
                                   fallback chain
  1. Routing — scores eligible models by trust tier, cost, and latency history
  2. Eligibility — filters models by intent, verbosity, and determinism requirements
  3. Fallback — tries models in order; switches on timeout, error, refusal, or rate limit
  4. Adapter — thin shim per provider; no shared state between providers
  5. 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
Google 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)

ghostcore supports maelspine for zero-import access to registries across a larger application:

from ControlCore.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
ghostcore   — LLM orchestration gateway  ← you are here
ghostserver — evidence server (Blackbox)

License

MIT — Copyright 2026 Adam Thomas / GhostLogic LLC

Release files for ghostcore 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ghostcore 0.1.1
File Size Uploaded
ghostcore-0.1.1.tar.gz 109.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ghostcore 0.1.1
File Interpreter ABI Platform
ghostcore-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 240.2 kB

Release files / ghostcore-0.1.1.tar.gz

Download URL ghostcore-0.1.1.tar.gz
Size 109.8 kB
Tags Source
SHA-256 checksum
How to use checksums
ca54a81d05673f0c04c794ee5e915c41398229ae65be9dd76799b0d6dd57cb92
BLAKE2b-256 checksum
How to use checksums
9854a427c492c32666b7ff9229e977b0b4f4e010158b1b03978ae63be937c36f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release files / ghostcore-0.1.1-py3-none-any.whl

Download URL ghostcore-0.1.1-py3-none-any.whl
Size 130.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
11073f487c3b39ac3aff4b2f8803291811ef5c0db2095d5fd6e6dfa941af6257
BLAKE2b-256 checksum
How to use checksums
3c03a800281aec8f6160e069eb2dbf6eb8012ba914508e2bbb6e782a62f4fcd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.10

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page