Warning
Deprecated / archived — use laya[serve] instead.
Upstream laya now ships
Jev-compatible serving natively (pip install "laya[serve]", same
laya-serve binary, POST /v1/systemone). This repo is read-only and
will receive no further releases. See Migration.
Jev-compatible HTTP server for Laya
System One decision models. Point any Jev client at this server and get typed
choice / score / noul answers from local Laya weights instead of the
TypeSafe API.
pip install "laya[serve]"
LAYA_PRELOAD=1 laya-serve # binds 0.0.0.0:8000, preloads all checkpointsThis repo (laya-serve) |
Upstream (laya[serve]) |
|---|---|
pip install "laya-serve[inference]" |
pip install "laya[serve]" (same laya-serve binary — uninstall this package first to avoid the script collision) |
LAYA_SERVE_DEVICE / LAYA_SERVE_PRELOAD |
LAYA_DEVICE / LAYA_PRELOAD (defaults to preloaded) + LAYA_MODELS, LAYA_THREADS, LAYA_MAX_CONCURRENT |
LAYA_SERVE_API_KEY |
LAYA_API_KEY |
GET /healthz |
GET /health (adds loaded / revisions / device) |
GET /v1/models |
No equivalent (removed) |
model outside the Jev allowlist → 422 |
Unknown model is ignored and the Router auto-selects; english / multilingual / typed-decisions (or their Hub ids) pin a checkpoint |
In-process 429 rate limiting |
Admission bound → 503 when saturated (enforce 429 at the gateway) |
fake backend for CI |
No equivalent (removed) |
Strict caps (choice ≤ 255, score 2–10, 64k/32k budgets → 422) and Jev {"error": {"message", "field"}} shape with 429/529 |
Upstream caps (2MB body, 64 questions, per-question option caps → 400/413/422) and plain {"detail": …} errors with 503/500 |
pip install "laya-serve[inference]"
LAYA_SERVE_BACKEND=laya LAYA_SERVE_PRELOAD=true laya-servecurl -X POST localhost:8000/v1/systemone \
-H "Content-Type: application/json" -d '{
"state": "Help! My payouts have been failing for 3 days.",
"model": "jev-latest",
"questions": {
"department": {
"type": "choice",
"instructions": "Which team should handle this?",
"criteria": {
"billing": "Payments, invoicing, refunds",
"technical": "Bugs, outages, integrations",
"sales": "Pricing, upgrades, new accounts"
}
},
"is_urgent": {"type": "noul", "instructions": "The message conveys urgency?"}
}
}'Without weights (API development, CI):
pip install -e ".[test]"
LAYA_SERVE_BACKEND=fake laya-serve # deterministic uniform answers| Method | Path | Notes |
|---|---|---|
POST |
/v1/systemone |
Jev-compatible evaluation endpoint |
GET |
/v1/models |
Serving model + accepted aliases |
GET |
/healthz |
Liveness probe (not part of the Jev API) |
Errors use {"error": {"message", "field"}} with Jev status codes
(401 bad key, 422 validation, 429 rate limit with a Retry-After
header when LAYA_SERVE_RATE_LIMIT_PER_MINUTE > 0, 529 transient overload
with a Retry-After header, 500 unexpected backend failure with internals
logged server-side).
| Variable | Default | Meaning |
|---|---|---|
LAYA_SERVE_BACKEND |
fake |
laya (real weights) or fake (weight-free) |
LAYA_SERVE_SERVING_MODEL |
laya-english |
Id reported in the model response field |
LAYA_SERVE_EXTRA_MODELS |
`` | Extra accepted model names, comma-separated |
LAYA_SERVE_DEVICE |
auto | Passed to the Laya Router (cuda, cpu, …) |
LAYA_SERVE_MAX_LOADED |
1 |
Router LRU cap on resident checkpoints |
LAYA_SERVE_PRELOAD |
false |
Preload all checkpoints (recommended for servers) |
LAYA_SERVE_API_KEY |
unset | When set, requires Authorization: Bearer <key> |
LAYA_SERVE_RATE_LIMIT_PER_MINUTE |
0 |
POST /v1/systemone limit per 60s window per client; 0 disables |
Accepted model names out of the box: jev-latest, jev-preview,
jev-1.13.0, jev-1.13, laya, laya-latest, plus the serving model id
itself. Anything else is a 422 (fail fast on typos, like Jev).
Verified against docs.typesafe.ai and laya 0.3.x source. Deliberate,
documented divergences:
- Laya-only fields are stripped:
actionon every answer, andconfidenceonnoulanswers. Responses contain exactly the Jev fields. modelechoes the serving checkpoint (e.g.laya-english), the same way Jev echoes the resolved version id (jev-1.13.0).output_tokensis0. Laya never generates tokens; this layer does not invent counts.input_tokensis the backend's token count.- Confidence formula differs: Laya uses entropy-based
1 - H(p)/log(k); Jev documents a peak-based normalization. Same probabilities can yield differentconfidencevalues — calibrate thresholds against Laya, not Jev. - Validation: choice ≤ 255 options, score 2–10 levels,
modelrequired, non-emptyquestions— all422. Context budgets mirror Jev's 64k (state + all questions) / 32k (state + longest question) accounting and surface as422, as do option sets overflowing the per-question head budget; request sizes use a deterministic word count on every backend so the200/422boundary is stable. The checkpoint still truncates per-question sequences at its ownmax_len. - Score
legend/probabilitieskeys are strings on the wire ({"0": …}), matching Jev HTTP. choicecriteria as a list is accepted leniently (mapped to{label: None}); Jev requires a map.
python -m venv .venv && .venv/bin/pip install -e ".[test]"
.venv/bin/python -m pytest -qOr with uv (reproducible, via uv.lock):
uv sync --extra test
uv run pytest -qLint/format via ruff and hooks via pre-commit:
uvx ruff check src tests && uvx ruff format --check src tests
pre-commit install && pre-commit run --all-filesVersioned docs (Zensical + mike): https://stiermid.github.io/laya-serve/
(latest tracks the newest v* tag with the v stripped, dev tracks master —
see docs/versioning.md).
uv sync --group docs
uv run zensical serve # local preview
uv run zensical build --strict # same check CI runsApache-2.0 — see LICENSE.