Skip to main content

Laya pass-through

The /laya/v1/systemone route forwards a native System One decisions request to the Laya server named by LAYA_API_BASE. System One asks typed questions about a piece of text and returns answers with probabilities. The gateway checks the virtual key, adds the Laya key when one is set and records the call. The model must be one of english, multilingual or typed-decisions, and streaming is not supported.

A real-world scenario​

A moderation team hosts a Laya decision server inside its own network and has tooling that speaks System One directly. Rather than opening the server to every tool, they expose it through the gateway. The tools call /laya/v1/systemone with virtual keys, the server accepts traffic only from the gateway, and every decision is attributed to a team.

Before you start​

The gateway needs the Laya server address.

VariablePurpose
LAYA_API_BASEThe Laya server, as a plain HTTP or HTTPS URL with no credentials, query or fragment.
LAYA_API_KEYOptional. Sent as a bearer token when the server requires one.

Steps​

  1. Set LAYA_API_BASE in the gateway environment and restart. There is no provider entry to add on the Models + Endpoints page for this route.

  2. Issue a virtual key on /ui/api-keys with + Create New Key, then Create Key.

  3. Send a System One request through the gateway.

    curl -X POST http://localhost:4000/laya/v1/systemone \
    -H "Authorization: Bearer $SPANWAY_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{"model": "english", "state": "Customer wrote: I was charged twice for order #4411 and want one charge refunded today.", "questions": {"is_refund_request": {"type": "noul", "instructions": "Is the customer asking for a refund?"}, "urgency": {"type": "choice", "instructions": "How urgent is this?", "criteria": {"low": "can wait a week", "high": "needs action today"}}}}'
  4. Open /ui/logs and click the newest row to see the request and the key that made it.

Expected result​

The Laya server's own response, with its status code and headers.

{
"model": "english",
"answers": {
"is_refund_request": {"type": "noul", "value": true, "probability": 0.97},
"urgency": {"type": "choice", "value": "high", "probabilities": {"low": 0.08, "high": 0.92}}
}
}

The spend log row carries the key, team and user.

Errors​

StatusMessageWhat it means and how to fix it
401Authentication Error, Invalid proxy server token passedThe virtual key is missing, wrong, expired or blocked.
403Key/team denied access to passthrough route /laya/v1/systemoneThe key or team lists the route in denied_passthrough_routes. The message goes on with Matched <pattern> in denied_passthrough_routes, naming the pattern to remove from the key or team.
400laya model must be one of english, multilingual, typed-decisionsThe model is not one Laya serves.
400Streaming is not supported for laya requests or custom_body is not supported for laya requestsRemove stream or custom_body from the body.
503laya server is not configured correctly; check LAYA_API_BASELAYA_API_BASE is missing or is not a plain server URL.
Any otherThe Laya server's own error bodyThe server refused the request. The message is returned unchanged.

Pass-through endpoints lists every built-in route. The Decisions API accepts both decision formats and any decision model. Bespoke Nimble pass-through and Typesafe pass-through cover the other System One servers.