Quick Start
import { Tabs, TabItem } from ‘@astrojs/starlight/components’;
Prerequisites
- Python 3.13+
- PostgreSQL 16+ with
vectorandltreeextensions - uv package manager
- Temporal Server (for ContextWorker)
1. Install ContextCore
ContextCore is the shared kernel — install it first.
pip install contextcoreOr add as a dependency in your project:
uv add contextcore2. Set Up ContextBrain
ContextBrain provides the knowledge store.
# Clone and installgit clone https://github.com/ContextUnity/contextbrain.gitcd contextbrainuv sync
# Create databasecreatedb brainpsql brain -c "CREATE EXTENSION IF NOT EXISTS vector;"psql brain -c "CREATE EXTENSION IF NOT EXISTS ltree;"
# Configureexport BRAIN_DATABASE_URL="postgres://user:pass@localhost:5432/brain"export BRAIN_PORT=50051export EMBEDDER_TYPE="openai" # or "local" for SentenceTransformersexport OPENAI_API_KEY="sk-..." # required for OpenAI embeddingsexport PGVECTOR_DIM=1536 # 1536 for OpenAI, 768 for local
# Initialize schema and startuv run python scripts/init_db.pyuv run python -m contextbrain3. Set Up ContextRouter
ContextRouter is the agent gateway.
git clone https://github.com/ContextUnity/contextrouter.gitcd contextrouteruv sync
# Configureexport ROUTER_PORT=50052export BRAIN_HOST="localhost:50051"export OPENAI_API_KEY="sk-..."
# Startuv run python -m contextrouter4. Your First Query
Once Brain and Router are running, connect from any Python script:
from contextcore import ContextUnit, create_channel_syncfrom contextcore import router_pb2, router_pb2_grpc
# Connect to Routerchannel = create_channel_sync("localhost:50052")stub = router_pb2_grpc.RouterServiceStub(channel)
# Send a queryunit = ContextUnit( payload={"query": "What is retrieval-augmented generation?"}, provenance=["client:quickstart"],)
response = stub.Route(unit.to_protobuf(router_pb2))print(response)5. Add ContextWorker (Optional)
For background jobs and scheduled tasks:
# Install and start Temporal (if not running)temporal server start-dev
# Clone and install Workergit clone https://github.com/ContextUnity/contextworker.gitcd contextworkeruv sync
# Configureexport WORKER_PORT=50053export TEMPORAL_HOST="localhost:7233"
# Startuv run python -m contextworkerWhat’s Next?
- Architecture — understand how services communicate
- ContextUnit Protocol — the universal data envelope
- ContextToken Security — capability-based authorization
- ContextRouter Agents — build multi-step reasoning agents
- ContextBrain RAG — configure retrieval-augmented generation