ModelRelay
ModelRelay runs recursive language models over private data. An RLM writes and executes code to inspect data, make targeted model calls, and synthesize an answer without forcing the entire dataset into one context window.
Use ModelRelay when an AI feature must reason across a database, a collection of files, or a large JSON payload—not merely retrieve one matching record.
Start with your data
The fastest path today is a local, read-only SQLite database:
brew install tensor-systems/tap/mrl
mrl config set \
--api-key "$MODELRELAY_API_KEY" \
--model claude-sonnet-5
mrl rlm \
"Which customers grew the most this quarter, and what drove the change?" \
--db ./app.db
Python and database access run on your machine. Model subcalls are routed through ModelRelay, and the RLM sends only the information it selects for those calls.
Why RLM?
Ordinary model requests work well when the relevant information already fits in the prompt. RLM is designed for questions that require exploration, iteration, aggregation, or computation across more data than a model should receive at once.
- Code as reasoning — The root model writes code to inspect and reduce the data.
- Adaptive decomposition — It can filter, query, aggregate, and use
llm_queryorllm_batchfor semantic work. - Private-data execution — The engine runs in your boundary: your machine, your VPC, or your application process.
- Model flexibility — Use a strong root model and a cheaper model for bounded subcalls.
- Auditable results — Every run reports its iterations, subcall count, and token usage; a leased run also freezes immutable per-role cost and settlement evidence.
Control plane, data plane
ModelRelay is the control plane. The engine — Python, data access, credentials — is the data plane, and it runs on your side of the boundary. ModelRelay authorizes the model routes, enforces budgets, meters every root and subcall request, and records immutable content-free evidence. It never receives your query, context, corpus, code, stdout, or stderr.
| Where the engine runs | Data it can reach | What ModelRelay does |
|---|---|---|
Your machine, via mrl rlm |
SQLite, PostgreSQL, Snowflake, MCP, files, stdin | Routes and bills root/subcall inference |
| Your VPC or application | Anything reachable inside your boundary | Same, plus optional budgeted execution grants with retrievable evidence |
Documentation
- Getting Started — Get an answer from SQLite or a local file.
- RLM — Learn how the loop works and when to use it.
- Data Sources — Connect SQLite, PostgreSQL, Snowflake, MCP, and local files.
- Models and Subcalls — Control model selection, budgets, and cost.
- Security and Data Boundaries — Understand what executes where and what can leave the boundary.
- CLI — Complete
mrl rlmusage. - RLM API Reference — Execution leases, budgets, and evidence.
Building for your users
ModelRelay can attribute every root iteration and subcall to the customer who initiated an RLM run. Use customer tokens, usage records, tiers, and Stripe-backed billing when you embed RLM in a multi-tenant product.
- Customer Tokens — Scope requests to an end user.
- Customer Billing — Meter and monetize usage.
- Tiers and Margins — Set limits and pricing.
For multi-step application flows, drive the engine from your own orchestrator — LangGraph, Temporal, or a job runner — and give each run its own execution grant so the spend ceiling and evidence are per-run.