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 — Run locally today, or place the runtime beside your data in your own deployment.
- Model flexibility — Use a strong root model and a cheaper model for bounded subcalls.
- Auditable results — Inspect the generated code, intermediate output, usage, and final answer.
Choose an execution mode
| Mode | Data available today | Where data access runs |
|---|---|---|
| Local CLI | SQLite, files, stdin | Your machine |
| Hosted RLM | Inline JSON, uploaded context, wrapper_v1 APIs |
ModelRelay-hosted runtime |
| Private deployment | Data sources reachable inside your boundary | Your VPC or infrastructure |
Hosted /rlm/execute does not accept direct database credentials. To keep credentials in your boundary, use local SQLite, a customer-hosted wrapper_v1 service, or a private deployment.
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 — Compare local files, SQLite, context handles, and hosted wrappers.
- 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 — Exact hosted request and response fields.
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.
Generic response APIs, workflows, agents, and compatibility endpoints remain documented under Additional Platform APIs and the API Reference, but they are not required to start with RLM.