Distributed inference for your Ollama servers, using Supabase as the primary broker. Point the official Ollama Python client at one gateway and let oshepherd route requests to your connected workers. Models and inference stay on your machines; prompts, jobs and results pass through Supabase.
Choose a walkthrough:
| Example | Where Supabase runs | Needs | Guide |
|---|---|---|---|
| Fully local | Docker containers on your machine, including Studio | Python 3.12, uv, Docker, Supabase CLI 2.116.0, psql, Ollama |
Local walkthrough |
| Supabase Cloud | Hosted project created by oshepherd share; Ollama stays on your machine |
Python 3.12, uv, a Supabase account, Ollama | Cloud walkthrough |
Both examples cover setup, Python requests, database inspection and restart. Once an installation is running, follow the worker onboarding walkthrough to add an Ollama server and watch its logs, the client onboarding walkthrough to give a script its own credentials, or the operations guide to run in the background, restart or disable an installation.
Supabase support is experimental and published as the 0.1.0rc1 release
candidate: uv tool install --python 3.12 'oshepherd[supabase]==0.1.0rc1'. See the
documentation index for installation, operations, database
references and development guides, and the progress ledger
for validation status.
Supabase is the broker. Postgres coordinates durable jobs and worker leases, Auth gives each worker a restricted identity, Storage holds larger results, and an Edge Function exposes the inference API to Ollama clients.
flowchart LR
C[Ollama Python client] -->|Application key| E[Supabase Edge gateway]
E <--> Q[Postgres jobs and output]
W[oshepherd worker] <-->|Outbound requests| Q
W --> O[Local Ollama]
W <--> S[Supabase Storage]
E <--> S
W --> A[Supabase Auth]
- A client sends an Ollama request to the Edge gateway with its application key.
- The gateway records a job in Postgres.
- A worker claims the job under a lease, runs it on its local Ollama, and writes output back to Postgres, or to Storage when the result is large.
- The gateway returns the result, or streams it, to the client.
Workers make only outbound connections to Supabase. A hosted installation does not need an inbound port or tunnel to Ollama. The same SQL, Auth, Storage and Edge path can be tested first with local Supabase containers.
oshepherd's original architecture is self-hosted: a FastAPI server receives Ollama requests and queues them as Celery tasks in Redis, which is both the message broker and the result backend. Celery workers, one next to each Ollama server, take tasks from the queue and run them on their local models. You run and secure all three parts yourself.
flowchart LR
C[Ollama Python client] --> F[FastAPI gateway]
F <--> R[Redis broker and results]
W[Celery worker] <--> R
W --> O[Local Ollama]
| Area | Supabase (primary) | Redis, Celery and FastAPI (legacy) |
|---|---|---|
| Start serving | oshepherd share / prepared local connection |
start-api and start-worker |
| Add workers | invite, then join with a private one-use invitation |
Configure the worker's Redis connection |
| Python client | Gateway URL plus application bearer key | FastAPI URL |
| Run infrastructure | Supabase; Ollama stays local | Redis, Celery and FastAPI |
| Guide | Local / Cloud | Redis setup |
The legacy stack remains supported. Existing start-api and start-worker
commands retain their Redis defaults; choosing Supabase does not migrate Redis
jobs or switch an existing deployment automatically.
oshepherd started as a way to give the kids at CodePeques, a technology academy in Venezuela that teaches children programming, robotics and design, access to large language models. Hosted LLM APIs such as OpenAI, Anthropic and Gemini were not available in Venezuela because of US sanctions, and deploying a custom model in the cloud was too expensive. Instead, oshepherd pooled the machines already on hand, each running open-source models with Ollama, behind one API. That setup served CodePeques classes and CodePeques Day in May 2024, with no orchestration or inference costs.
The legacy stack was presented at PyCon Austria 2025 in the talk "Beyond the Cloud: On-Premise Orchestration for Open-Source LLMs". For a practical example of orchestrating on-premise open-source LLMs with oshepherd, see the companion material:
- Repository: https://github.com/mnemonica-ai/on-premise-orchestration-os-llms
- Deck: https://speakerdeck.com/p1nox/beyond-the-cloud-on-premise-orchestration-for-open-source-llms
client.json contains the gateway URL and your private application key. The URL
includes /functions/v1/ollama; it is not the database REST endpoint.
This example uses the manual local walkthrough's state directory. For cloud,
use .oshepherd/cloud/first-run/client.json, or use a named client's export.
import json
from pathlib import Path
from ollama import Client
settings = json.loads(Path(
".oshepherd/local/end-user/operator/client.json"
).read_text())
client = Client(
host=settings["gateway_url"],
headers={"Authorization": "Bearer " + settings["application_key"]},
timeout=145,
)
for chunk in client.chat(
model="llama3.2:3b",
messages=[{"role": "user", "content": "Say hello in one sentence."}],
options={"num_predict": 32},
stream=True,
):
print(chunk.message.content or "", end="", flush=True)Both Client and AsyncClient are exercised in the local acceptance workflow.
The supported routes match the existing Redis endpoint set:
| Operation | Route | Python client |
|---|---|---|
| Generate, JSON or streaming | POST /api/generate |
generate() |
| Chat, JSON or streaming | POST /api/chat |
chat() |
| Legacy embeddings | POST /api/embeddings |
embeddings() |
| System One decisions | POST /v1/systemone |
systemone() |
| Available models | GET /api/tags |
list() |
| Running models | GET /api/ps |
ps() |
| Model information | POST /api/show |
show() |
| Version | GET /api/version |
Authenticated HTTP request |
| Gateway health | GET /health |
Authenticated HTTP request |
This is the existing oshepherd API contract, not full upstream Ollama parity.
embed() (/api/embed), model pull/create/delete and additional request fields
are outside this milestone. The existing show response wraps upstream model
information inside model_info. Legacy embeddings accepts the Python SDK's
prompt as well as input.
System One requires a compatible installed decision model. Models advertising
the decision capability are registered automatically. The
acceptance guide
explains how to include real decision inference in validation.
Synchronous requests have a 135-second budget, including queueing and model
loading. Edge request/response bodies are capped at 1 MiB. The asynchronous
/jobs API supports longer work and results up to 32 MiB, using a separate client
flow. Closing a streaming client does not yet reliably cancel inference
through the Edge proxy; this remains a release qualification gate.
See the remaining plan, compatibility matrix and progress ledger. Supabase is the primary workflow, but the candidate is not production-qualified.
uv sync --locked --extra supabase --extra installer
uv run --locked pytest -q tests/contracts tests/test_systemone.py
# After changing packaged Python or Edge sources:
uv run --locked python -m scripts.build_supabase_release
uv buildKeep SQL migrations immutable. Refresh the release manifest after source changes
before running release-integrity tests. uv.lock records dependency versions;
requirements/runtime.txt is the locked runtime export used for clean candidate
verification. Installation covers local wheel testing. The
disposable acceptance workflow tests a fresh stack
and removes its own test database when it finishes.
The local integration runbook covers the isolated development stack and its strict disconnect test. The operator runbook covers upgrade, diagnostics, rotation, revocation and disablement. Redis tests and startup instructions remain in the legacy guide.
Contributions are welcome through issues and pull requests.
Developed by mnemonica.ai. MIT license. Supabase's unmodified logo comes from its official brand assets. The Redis and FastAPI logos come from Devicon; the Celery logo comes from its official project repository.
