Use local and hosted decision models through one API. One System sits between your application and compatible TypeSafe System One servers. Send your data and questions once; choose a backend directly or let a model help decide where the request should run.
These models return decisions your code can use: Choice selects an option, Noul gives the probability of yes, and Score rates against levels you define. They return typed answers and probabilities, rather than writing a chat reply.
Use One System to:
- Keep one client interface while trying different models or hosting arrangements.
- Handle suitable tasks locally and send other tasks to hosted Jev.
- Run entirely locally by choosing a configuration with no hosted backend.
The example below uses local Laya to select between local Laya and hosted Jev. One System is the project; Privacy Demo is one example configuration you can adapt. Its current rule classifies the task's domain, not whether the input contains private information.
Install the gateway on Linux or macOS (amd64/arm64):
curl -fsSL https://github.com/rawwerks/one-system/releases/latest/download/install.sh | shReview the installer before trusting it. It verifies the selected
archive's checksum, installs under ~/.local/share/one-system, and creates
~/.local/bin/one-system. It does not use sudo, start services, change shell
profiles, or overwrite an existing installation or launcher. See
installation options to inspect the installer first, pin a
version, choose destinations, or install from local bundles.
Then choose your setup guide:
No Go installation or compiler is needed to run the gateway. Local Laya runs as a separate service with its own adapter and model checkpoint.
The guides start Laya locally on port 8091 and the gateway on port 8090, using
the privacy-demo configuration. This demo also needs a TypeSafe API key for
requests it sends to hosted Jev; those calls can incur charges.
In a new terminal, return to the installed gateway directory and load the configuration you created in the setup guide:
set -a; . ./.env; set +aAsk a simple question using automatic routing:
curl --fail-with-body \
-H "Authorization: Bearer $ONE_SYSTEM_API_KEY" \
-H 'Content-Type: application/json' \
http://127.0.0.1:8090/v1/systemone \
--data-binary '{
"model": "privacy-demo",
"state": "Please refund the duplicate charge for my subscription.",
"questions": {
"refund_requested": {
"type": "noul",
"instructions": "Does the customer request a refund?"
}
}
}'The response contains answers.refund_requested.noul, the probability of yes,
and model, the backend's model identity. In the gateway terminal, the route
log identifies which backend handled the request.
To try the demo's math escalation rule, send this second request:
curl --fail-with-body \
-H "Authorization: Bearer $ONE_SYSTEM_API_KEY" \
-H 'Content-Type: application/json' \
http://127.0.0.1:8090/v1/systemone \
--data-binary '{
"model": "privacy-demo",
"state": "17 + 25 = 42",
"questions": {
"correct": {
"type": "noul",
"instructions": "Is the arithmetic calculation correct?"
}
}
}'For these small requests, Laya first judges the domain of your question
instructions. The demo rule sends the full
request to Jev when Laya assigns math_or_logic a probability above 0.5; otherwise
Laya answers it locally. The routing question
and threshold are editable examples. Inspect your results rather than assuming
either example always takes a particular route.
Privacy Demo is not a privacy filter. It does not inspect the input for
sensitive data, and a request with only one eligible backend skips model-based
selection, even if that backend is hosted. Use the local-only configuration
with model: "local-demo" when requests must stay local. See
routing and disclosure before
adapting the mixed demo to real data.
Set ONE_SYSTEM_CONFIG in .env, reload it, restart the gateway, and use the corresponding
model in your requests. Each gateway process loads one configuration.
| Example | Configuration | Use it for |
|---|---|---|
privacy-demo |
examples/privacy.backends.json |
Local task selection with rule-based hosted escalation |
local-demo |
examples/local.backends.json |
Local Laya only; no hosted key needed |
routing-demo |
backends.json |
Hosted selection across local and hosted backends |
jev-lint |
examples/jev-lint.backends.json |
Hosted code-review judgments with a pinned Jev model |
Or set a request's model to a backend ID such as local or hosted to bypass
selection. A direct call does not silently substitute another backend.
examples/laya_jev_ensemble.py composes three native
System One requests using the official async Python SDK. Laya and Jev answer the
same questions concurrently; Jev then sees the original evidence and both typed
judgments and answers those original questions again. The gateway stays unchanged.
Start local Laya and a gateway configured with both local
and hosted backends (backends.json or examples/privacy.backends.json).
Then, from the repository root:
make setup-examples
TYPESAFE_ENDPOINT=http://127.0.0.1:8090 TYPESAFE_API_KEY="$ONE_SYSTEM_API_KEY" \
.build/example-venv/bin/python examples/laya_jev_ensemble.py \
--laya-model local --jev-model hosted --output .build/ensemble-demoUse the gateway's API key here, not the hosted TypeSafe key. Both model arguments
are explicit backend IDs, bypassing automatic selection. The versioned
laya-jev-ensemble.json contains only public
synthetic input and the adjudication instructions. Two requests go to hosted Jev
and may incur charges; this is a feasibility example, not evidence of better accuracy.
Stdout is one standard {model, answers, usage} response: composite identity
laya-jev-ensemble-v1, the adjudicator's answers, and summed usage from all three
responses. Optional --output must name a new directory; it retains stage
request/response bodies, timing/model provenance, and the final result, but no
headers or credentials. Omit it to print only the final response. Failed or
invalid stages stop the example without retries, fallback, or a partial answer.
An unsuccessful output directory contains an incomplete report and whatever
stage bodies were available before failure; it never contains a final response.
composition/ is optional client-side TypeScript above the HTTP
API, with no package dependencies. run executes components under one budget
and deadline; patterns.mts shows routing, fan-out
with adjudication, and recursive classification built from ordinary code and
native System One requests. The gateway is unchanged.
One System ships no LLM client and hosts no text generation. When an application
needs new text, including new System One questions, it supplies a Generate
function and One System checks what comes back:
- An agent CLI you already use, in print/exec mode:
agentCli('claude', ['-p']),agentCli('pi', ['-p'])oragentCli('codex', ['exec']). The prompt goes to stdin and the answer comes from stdout; model, login and subscription stay with the CLI. - Your own API call, for example the OpenAI Responses API with plain
fetch. Copy and adapt it; you own the key, model and client.
generateChecked validates each draft, feeds the reason back and retries.
questionAuthor does this for System One questions: it gives the generator the
official schema from the pinned OpenAPI description,
the target route's limits from GET /v1/capabilities, and
question-writing guidance, then checks the
result with the gateway's own validator. Your code keeps model and state.
node examples/generators/author-questions.mts --agent 'claude -p' --model local-demo \
--task 'Detect refund requests and how urgent they are' [--state state.json]The agent's zero exit status is not trusted: some CLIs print provider errors to stdout and exit 0, and such output is rejected and retried like any invalid draft.
Give your registry a name, list compatible HTTP backends, and choose your
selector and fallback. The configuration guide explains
credentials, routing rules, and adding an external server. The native API uses
POST /v1/systemone; there is no chat-completions endpoint.
Optional backend capabilities declare hard constraints: question_types,
max_questions, min_criteria, max_criteria, and structured_state.
question_types is required when capabilities are declared; structured_state: false means string state only. Constraints apply to the actual request on every
route, including selection and fallback. Unsupported requests return HTTP 422
unsupported_capability; questions are not dropped, truncated, or reinterpreted.
Omitted capabilities mean unknown. Backend servers still validate their exact
model and context limits. See configuration
for the JSON format.
Decision caching and full request/response recording are optional and off until configured. Cache identical requests to avoid repeated inference; enable recording to retain gateway and upstream exchanges, including cache hits and failures. They can be used separately or together. Recording contains sensitive bodies and has its own retention policy, independent of cache eviction. See cache configuration and recording configuration.
With Go 1.23 or newer, Git, and Make installed (repository access is currently required):
git clone --recurse-submodules https://github.com/rawwerks/one-system.git
cd one-system
make setup buildRun bin/one-system instead of ./one-system in the setup guides.
An independent Hono implementation supports Node and Cloudflare
Workers with the same HTTP interface and configurations.
Give your agent the One System user skill for using this gateway and its examples. It points to TypeSafe's separately maintained skill; follow the official TypeSafe installation instructions to load that skill in your agent too.
- Suggest a skill: combine ranking and verification through the same API.
- Review a repository before making it public: read every non-ignored file from many angles in one request per chunk.
- Review a backend integration: check a candidate server before adding it.
- TypeSafe questions and primitives: design typed decisions for your application.
- Contribute: development setup, mandatory local checks, and local-first releases; hosted workflows run only on explicit request.
One System is available under the MIT License. Two things in this repository belong to TypeSafe and are not covered by it: the OpenAPI description of the System One API, and the TypeSafe skill, a pinned submodule under its own MIT license.