llamay reference
Every gateway config field, Agent field, Helm value, admin route, ledger record, error, metric, CLI flag and port of the MAQPNA integration with the llamay inference engine.
This page lists everything that configures or reports on the llamay integration, as the MAQPNA source defines it (cmd/maqpna-gateway/llamay.go, llamay_checkpoint.go, pkg/llamay, internal/controller/models_controller.go, deploy/helm/maqpna, cmd/maqpna/dev_integrations.go). For a step-by-step setup, read Use llamay models with MAQPNA.
When an endpoint is a llamay endpoint#
The gateway gives an endpoint the llamay behaviour (context binding, context fork, llamay_session stripping, audit gating) when any of these holds:
| Condition | Where it is set |
|---|---|
The route's provider is llamay |
models or modelsFile in gateway config; rendered by the operator from Agent.spec.model.provider: llamay |
A fallback's provider is llamay |
models.<route>.fallbacks[].provider in gateway config |
The endpoint's scheme://host equals that of llamay.upstream |
The Helm chart sets llamay.upstream to its in-cluster llamay |
provider is compared exactly in gateway config: write llamay in lower case. llamay is OpenAI-compatible, so the gateway uses the openai adapter for it.
Gateway config: llamay#
The llamay block of gateway.json (LlamayConfig). All fields are optional. Without the block, and without a route that says provider: llamay, nothing changes.
| Field | Type | Default | Meaning |
|---|---|---|---|
upstream |
string (URL) | "" |
OpenAI base URL of a managed llamay, for example http://maqpna-llamay.maqpna-system.svc:8081/v1. Every endpoint on its origin is a llamay endpoint, whatever its provider. Must be http or https with a host and no user info. |
apiKeyFile |
string (path) | "" |
Key file presented as Authorization: Bearer to endpoints on upstream's origin that have no apiKeyFile of their own. Re-read on every call. |
stateless |
bool | false |
true turns per-session context binding and context fork off. llamay_session is still stripped from agent requests. |
contextIdleSeconds |
int | 1800 |
Drop a session's context (DELETE /v1/contexts/{id}) after this many seconds without a call. Must be >= 0; 0 means the default. llamay itself expires idle contexts after 2 hours. |
maxContexts |
int | 4096 |
Most contexts this gateway keeps bound. Above it, the least recently used idle binding is dropped. Must be >= 0; 0 means the default. |
quarantineSnapshotDir |
string (path) | "" |
When set, a quarantined session's contexts are saved as llamay snapshots here (mode 0600) before they are dropped. The ledger records each file's SHA-256. Unset, quarantine drops them like any revocation. |
checkpointDir |
string (path) | "" |
Turns on the checkpoint routes. Checkpoint files are written here (mode 0600). Unset, both routes answer 409. maqpna dev up --llamay sets .maqpna/checkpoints/llamay. |
auditAnchors |
array | [] |
llamay request-audit files to verify and anchor in the ledger. See below. |
llamay.auditAnchors[]#
| Field | Type | Default | Meaning |
|---|---|---|---|
name |
string | required | Anchor name: ^[A-Za-z0-9][A-Za-z0-9._-]{0,62}$, unique. Appears as llamayAuditAnchor in records and as the anchor metric label. |
file |
string (path) | required | The file llamay writes with llamay serve -audit FILE. The gateway must be able to read it. |
intervalSeconds |
int | 60 |
Seconds between verifications. Must be >= 0; 0 means the default. dev up --llamay uses 10. |
continuation |
bool | false |
Accept a first record that continues an earlier file (llamay -audit-continue). |
failClosed |
bool | false |
While this chain is unverified, take every llamay endpoint out of model routing. dev up --llamay and the chart set true. |
How an anchor is checked:
- At gateway start, every anchor is verified once before the first request, so a
failClosedanchor gates routing from the start. - Each interval, the gateway verifies what was appended since the last verified offset.
- Every 30th check re-verifies the whole file against the pinned verified head. This catches an in-place edit of an old record.
- A shorter file is treated as a rotation. It must continue the verified head or start a new chain from genesis. A new chain is anchored at once with
llamayAuditRestartedFrom(seq:hashof the replaced head). - A
llamay/audit-anchorrecord is written whenever the head moves, and allamay/audit-unverifiedrecord once per distinct failure. A failed ledger append is retried with backoff.
Startup validation errors (the gateway does not start):
| Error | Cause |
|---|---|
llamay.upstream: invalid URL "<url>" |
Not http(s), no host, or user info in the URL. |
llamay: contextIdleSeconds and maxContexts must be >= 0 |
A negative value. |
llamay.auditAnchors[<i>]: name "<name>" is invalid or duplicate |
Bad or repeated anchor name. |
llamay.auditAnchors[<i>]: file is required |
No file. |
llamay.auditAnchors[<i>]: intervalSeconds must be >= 0 |
A negative interval. |
Gateway config: model route fields used with llamay#
A llamay route is an ordinary entry under models (or in modelsFile, which the operator writes as ConfigMap maqpna-models). The fields that matter for llamay:
| Field | Type | Meaning for llamay |
|---|---|---|
upstream |
string | llamay's OpenAI base URL, including /v1, for example http://127.0.0.1:11435/v1. |
provider |
string | llamay turns the integration on for this endpoint. |
model |
string | Forced into every request body. Use the name llamay reports in /healthz or /v1/models. It is also part of the context binding key. |
apiKeyFile |
string | llamay's key file (llamay -api-key or LLAMAY_API_KEY). Overrides llamay.apiKeyFile. |
jurisdiction |
string | Where llamay runs, for example EU-DE. Used by residency checks and jurisdiction-aware routing. |
fallbacks[] |
array | Tried when llamay fails, is rate-limited or is out of routing (llamay_audit_unverified). A fallback may set its own provider: llamay. |
All route fields are in the gateway configuration reference.
Agent fields for provider llamay#
Agent.spec.model (Agent CRD):
| Field | Type | Validation | Meaning for llamay |
|---|---|---|---|
provider |
string | max 128 characters | llamay (any case) makes the operator render "provider": "llamay" into the route. Other values are informational and not rendered. |
adapter |
enum | openai, azure-openai, bedrock, vertex, gemini, anthropic, oci-genai |
With provider: llamay, must be unset or openai. Otherwise the API server rejects the Agent: provider llamay is OpenAI-compatible: adapter must be unset or openai. |
endpoint |
string | ^https?://[^/?#@]+ |
llamay's address. A bare host gets /v1 appended; a trailing /chat/completions is stripped. |
name |
string | — | The model llamay serves. Rendered as the route's model. |
jurisdiction |
string | ^[A-Za-z]{2}(-[A-Za-z0-9]{1,8})*$ |
Rendered as the route's jurisdiction. |
apiKeySecretRef |
object | — | Needed only for a llamay outside the chart. For the chart's llamay, the gateway presents the chart's key. |
tokensPerMinute, maxTokensPerRequest, requestsPerMinute, dlpProfile, fallbacks |
— | as for any model | Apply unchanged. fallbacks[] has no provider field, so a fallback rendered from an Agent is a llamay endpoint only when it is on the chart's llamay origin. |
The route name is <namespace>.<agent> (characters outside [A-Za-z0-9._-] become -; names over 63 characters are shortened with a hash). The sandbox gets MAQPNA_MODEL_ENDPOINT={gateway}/llm/<route>/v1.
Helm values#
The llamay block of the chart's values (Helm values):
| Value | Default | Meaning |
|---|---|---|
llamay.enabled |
false |
Run llamay in the release and wire the gateway to it. |
llamay.name |
maqpna-llamay |
The app.kubernetes.io/name label of the llamay objects. |
llamay.image.registry |
"" |
Empty: llamay's public release registry. Under airgap.imageRegistry, the mirror is used. |
llamay.image.repository |
"" |
Empty: llamay's public repository. |
llamay.image.tag |
"0.4.5" |
Image tag. profile: cuda appends -cuda. |
llamay.image.digest |
"" |
Pin by digest instead of tag. |
llamay.image.pullPolicy |
IfNotPresent |
|
llamay.profile |
cpu |
cpu or cuda. cuda passes -gpu and requests a GPU. Any other value fails the render. |
llamay.gpu.count |
1 |
GPUs requested with profile: cuda. |
llamay.gpu.resourceName |
nvidia.com/gpu |
GPU resource name. |
llamay.model |
"" |
Required when enabled: a GGUF path under /models or a llamay store name (llamay serve -m). |
llamay.port |
8081 |
Container and Service port; llamay listens on 0.0.0.0:<port>. |
llamay.concurrency |
2 |
Generations at once (-concurrency). |
llamay.ctxMemBudget |
"" |
KV memory per model before idle contexts spill to disk (-ctx-mem-budget, for example 8G). Empty: keep all in memory. |
llamay.extraArgs |
[] |
Extra llamay serve flags. |
llamay.apiKey.existingSecret |
"" |
Secret holding the key. Empty: the chart generates <fullname>-llamay-key (for example maqpna-llamay-key) and keeps it across upgrades. |
llamay.apiKey.key |
api-key |
Key in that Secret. Mounted into the gateway only, at /var/run/maqpna-llamay/<key>. |
llamay.models.persistence.enabled |
true |
Models PVC. |
llamay.models.persistence.size |
20Gi |
|
llamay.models.persistence.storageClass |
"" |
|
llamay.models.persistence.accessModes |
[ReadWriteOnce] |
|
llamay.models.persistence.existingClaim |
"" |
Use an existing PVC. |
llamay.models.pull |
"" |
Pull the model at start with llamay pull in an init container. Opens HTTPS egress for the llamay pod. Refused with airgap.enabled. |
llamay.models.bundle.image |
"" |
Air-gapped model bundle image, copied into /models by an init container. Not together with pull. |
llamay.models.bundle.path |
/bundle |
Path of the store or GGUF files in the bundle image. |
llamay.audit.persistence.size |
5Gi |
Audit PVC, annotated helm.sh/resource-policy: keep. |
llamay.audit.persistence.storageClass |
"" |
|
llamay.audit.persistence.accessModes |
[ReadWriteOnce] |
Must include ReadWriteMany for anchor.enabled, because the gateway mounts the volume read-only. |
llamay.audit.anchor.enabled |
false |
Add anchor in-cluster (file /var/lib/llamay-audit/audit.jsonl) to the gateway. |
llamay.audit.anchor.intervalSeconds |
60 |
|
llamay.audit.anchor.failClosed |
true |
|
llamay.resources |
requests cpu: 1, memory: 2Gi; limits memory: 8Gi |
|
llamay.nodeSelector, tolerations, affinity |
{}, [], {} |
Scheduling. |
The chart always runs llamay with -audit /var/lib/llamay/audit/audit.jsonl -audit-strict -audit-sync: a record that cannot be written stops llamay serving rather than going missing. Keys you set in gateway.config.llamay take precedence over the ones the chart renders (upstream, apiKeyFile); with anchor.enabled, the chart sets auditAnchors.
Render errors: llamay.profile must be cpu or cuda, llamay.enabled requires llamay.model ..., set llamay.models.pull or llamay.models.bundle.image, not both, llamay.models.pull downloads from the internet; with airgap.enabled use llamay.models.bundle.image, and llamay.audit.anchor.enabled requires llamay.audit.persistence.accessModes to include ReadWriteMany ....
Admin routes#
Both need an admin credential with role admin (the static MAQPNA_ADMIN_TOKEN locally; see the admin API) and llamay.checkpointDir.
POST /v1/sessions/{id}/llamay:checkpoint#
Body: {"namespace": "dev"}. Saves every context bound to session {id} in that namespace (GET /v1/contexts/{ctx}/snapshot on llamay).
{"session": "plan-1", "namespace": "dev", "checkpoints": [
{"route": "llamay", "upstream": "http://127.0.0.1:11435/v1", "model": "<model>", "context": "ctx_<32 hex>",
"agent": "coder", "user": "you@localhost", "file": "<session>-<context>-<stamp>.llamay-snapshot",
"sha256": "<hex>", "bytes": 123456}]}
A session with no bound context returns an empty checkpoints list.
POST /v1/sessions/{id}/llamay:restore#
Body: {"namespace", "parentSession", "checkpoints": [...]}, where checkpoints is the list the checkpoint route returned and parentSession is the checkpointed session. Each file must be a plain name matching ^[A-Za-z0-9._-]{1,200}\.llamay-snapshot$ in checkpointDir, and its SHA-256 must match. The gateway loads it with POST /v1/contexts/restore?model= and binds session {id} to the new context.
{"session": "plan-1-restored", "parentSession": "plan-1",
"restored": [{"route": "llamay", "model": "<model>", "context": "ctx_<new>", "from": "ctx_<old>"}]}
Errors of the admin routes#
| Status | Message (starts with) | Cause |
|---|---|---|
409 |
llamay.checkpointDir is not set: session checkpoints are off |
No checkpointDir. |
400 |
body must be {"namespace": "..."} / body must be {"namespace", "parentSession", "checkpoints": [...]} |
Missing fields or bad JSON. |
400 |
restore into a new session, not the checkpointed one |
{id} equals parentSession. |
403 |
session <s> is revoked (<id>): its llamay state is not restored |
The checkpointed or the new session is revoked. |
503 |
revocation list unavailable: ... |
Revocations cannot be read; nothing is restored. |
409 |
no llamay endpoint <upstream> on route "<route>" any more: ... |
The route changed since the checkpoint. |
400 |
invalid checkpoint file name / checkpoint <f>: sha256 ... does not match the recorded ... |
Bad name or altered file. |
502 |
llamay snapshot of context ... / llamay restore of ... |
llamay refused or failed, for example 403 from a llamay that enforces classification markings. |
Ledger records and ext keys#
Model calls on a llamay endpoint are ordinary model-call records (server llm/<route>, tool such as chat.completions) with these ext keys:
| Ext key | On | Meaning |
|---|---|---|
llamayContext |
model calls, llamay/* records |
The context the call ran in. The same id is the context field of llamay's own audit record. Removed when the call ran unbound after a 404 or 409. |
llamayContextParent |
a forked or restored session's first call; llamay/context-restored |
The context it was forked or restored from. |
Observation records (decision observe), by rule:
| Rule | Written when | Ext keys |
|---|---|---|
llamay/audit-anchor |
An anchor's verified head moved. | llamayAuditAnchor, llamayAuditSeq, llamayAuditHead; llamayAuditRestartedFrom after a new chain replaced the verified one |
llamay/audit-unverified |
An anchor newly fails (once per distinct failure). | llamayAuditAnchor, llamayAuditSeq, llamayAuditHead (last verified head) |
llamay/context-revoked |
A revocation matched a session with a bound context, and the context was dropped (or not, with the reason). | llamayContext, revocation; for a quarantine with quarantineSnapshotDir: llamaySnapshot, llamaySnapshotSha256, llamaySnapshotBytes, or llamaySnapshotError |
llamay/context-checkpoint |
The checkpoint route saved a context. | llamayContext, llamayCheckpoint (file), llamayCheckpointSha256, llamaySnapshotBytes |
llamay/context-restored |
The restore route bound a session to a restored context. | llamayContext, llamayContextParent, llamayRestoredFrom, llamayCheckpoint, llamayCheckpointSha256, parentSession |
Other events that drop contexts: a session that reports its result (POST /v1/sessions/self/result) loses its contexts at once; a GDPR erasure (DELETE /v1/memory/users/{user}) drops that user's contexts and lists llamay in the certificate's backends; a quarantine incident lists the dropped contexts as a step.
Errors agents see#
| Status | Type | Code | When |
|---|---|---|---|
503 |
maqpna_upstream_error |
llamay_audit_unverified |
A failClosed anchor does not verify and no non-llamay endpoint is left on the route. Message: llamay request audit is unverified (llamay.auditAnchors failClosed). Audited as a denial with policy model-routing, rule llamay_audit_unverified. |
A bound context that llamay answers with 404 (expired, llamay restarted) or 409 (in use) is not an error for the agent: the gateway retries the call once unbound, and on 404 forgets the binding. A context create or fork that fails makes the call run unbound (fork first falls back to create). All other model errors are the usual ones in Error and reason codes.
Metrics#
From the gateway's GET /metrics (all metrics):
| Metric | Type | Labels | Meaning |
|---|---|---|---|
maqpna_gateway_llamay_contexts |
gauge | — | Contexts bound to governed sessions. |
maqpna_gateway_llamay_context_ops_total |
counter | op: create, fork, drop, stale, busy, error, checkpoint, restore |
Context operations. stale: a 404 forgot a binding. busy: a concurrent call of a session ran unbound. |
maqpna_gateway_llamay_audit_verified |
gauge | anchor |
1 while the chain verifies. Only with anchors. |
maqpna_gateway_llamay_audit_head_seq |
gauge | anchor |
Last verified seq. |
maqpna_gateway_llamay_anchor_append_failures_total |
counter | anchor |
Anchor records the ledger could not append (retried with backoff). |
maqpna_gateway_model_endpoint_skipped_total |
counter | route, endpoint, reason |
With reason="llamay_audit_unverified": llamay endpoints skipped by a failClosed anchor. |
llamay exports its own metrics on its /metrics.
CLI#
maqpna dev up flags#
| Flag | Default | Meaning |
|---|---|---|
--llamay MODEL |
"" |
Start llamay serve with MODEL (GGUF path or store name) as model route llamay, with per-session contexts, context fork, checkpoints and the audit anchored with failClosed. |
--llamay-bin PATH |
llamay next to maqpna, then on PATH |
The llamay binary. |
--llamay-port N |
11435 |
llamay's port on 127.0.0.1. |
Files it writes in .maqpna/: llamay.key (0600), llamay-audit.jsonl, logs/llamay.log, checkpoints/llamay/. maqpna dev run then exports OPENAI_BASE_URL, MAQPNA_MODEL_ENDPOINT ({gateway}/llm/llamay/v1), MAQPNA_MODEL_PROVIDER=openai, MAQPNA_MODEL_NAME and, outside a sandbox, OPENAI_API_KEY. With --stub-llm too, the stub route is the one exported. See maqpna dev up.
Commands that carry llamay state#
| Command | llamay effect |
|---|---|
maqpna dev fork |
The child token names the parent; the child's first model call forks the parent's context. |
maqpna dev snapshot |
Calls llamay:checkpoint first, then snapshots the sandbox. A failed checkpoint is recorded as llamayError in the checkpoint file; the snapshot still happens. |
maqpna dev restore |
Boots the snapshot as a new session and calls llamay:restore. On 403 (revoked) it removes the restored sandbox. |
maqpna llamay verify-audit#
maqpna llamay verify-audit [--continuation] FILE... [-o json]
| Flag | Meaning |
|---|---|
--continuation |
The first file continues an earlier one (llamay serve -audit-continue). |
Give rotated files oldest first. Output: llamay audit chain verified: <records> records, head seq <seq> <hash>, or llamay audit chain BROKEN: <error> (verified through seq <seq>). With -o json: verified, records, headSeq, headHash and, on failure, error. Exit code 0 verified, 3 broken. See maqpna llamay verify-audit.
Ports and endpoints between the gateway and llamay#
| Where | llamay address |
|---|---|
maqpna dev up --llamay |
127.0.0.1:11435 (--llamay-port) |
| Helm chart | Service <release>-llamay (for example maqpna-llamay), port 8081 (llamay.port); only gateway pods may connect |
| llamay's own default | localhost:11435 |
Routes the gateway calls on llamay, always with the gateway's key:
| Route | Used for |
|---|---|
POST /v1/chat/completions, POST /v1/completions |
Generations, with llamay_session set to the bound context |
POST /v1/embeddings, GET /v1/models |
Proxied unbound |
POST /v1/contexts |
Create a session's context ({"model"}) |
POST /v1/contexts/{id}/fork?n=1&model= |
Fork the parent's context for a child session |
DELETE /v1/contexts/{id}?model= |
Drop a context (idle, ended, revoked, erased, evicted) |
GET /v1/contexts/{id}/snapshot?model= |
Checkpoint or quarantine snapshot |
POST /v1/contexts/restore?model= |
Restore a checkpoint |
GET /healthz |
maqpna dev up readiness and the model name (no key needed) |
Agents reach llamay only through /llm/{route}/v1/chat/completions, /completions, /embeddings and /models on the gateway; llamay's context routes, Anthropic and Ollama routes are not proxied. Every gateway call to llamay goes through the gateway's residency-checked dialer.