Introduction
layahost is a hosted API for typed decisions. You send a piece of text and a question with a fixed set of answers. You get back one of those answers, with probabilities, as JSON your code can branch on.
It runs Laya, the open-source decision model by Convai Innovations (Apache-2.0), and implements the wire format of TypeSafe AI's Jev System One API. Code written for Jev, including the official Jev SDKs, works after you change the base URL and the API key.
How it works
Every question has a type, and every answer is typed to match:
| Type | You define | You get back |
|---|---|---|
choice | 2 or more named options, optionally with a description each | The chosen option and a probability for every option |
yes/no (noul in Jev) | A yes/no question | The probability that the answer is yes |
score | 2 to 10 ordered levels, lowest first | The expected level and a probability for every level |
Laya is a classifier, not a text generator: it never writes free text, so every answer is one of the options you defined. There is nothing to parse and no malformed output to retry. Server-side processing typically takes tens of milliseconds, and every response reports its own latency_ms.
Typical uses are content moderation, spam filtering, support-ticket intent and routing, sentiment and urgency scoring. Accuracy depends on your data and on how you word the question, so test on a sample of real traffic before you rely on it.
Two endpoints
| Endpoint | Use it when |
|---|---|
POST /v1/decide |
You want one decision about one text. Use a ready-made template (moderation, spam, routing and more) or your own question. The response is flat and easy to read. |
POST /v1/systemone |
You want the Jev-compatible API: up to 32 questions about the same text in one request, and the official Jev SDKs for Python and JavaScript. |
Quickstart
- Create an account and add credit on the Billing page. Verifying your email adds $1 of welcome credit (200K decisions), enough to try everything. The smallest top-up is $10, which buys 2,000,000 decisions.
- Create a key on the API keys page and store it as
LAYAHOST_API_KEY. The key is shown only once. - Send your first request:
curl https://layahost.com/v1/decide \
-H "Authorization: Bearer $LAYAHOST_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"text": "I was charged twice this month, please refund one payment.",
"template": "support_intent"
}'
const res = await fetch("https://layahost.com/v1/decide", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.LAYAHOST_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
text: "I was charged twice this month, please refund one payment.",
template: "support_intent",
}),
});
const result = await res.json();
console.log(result.decision, result.confidence);
import os
import requests
res = requests.post(
"https://layahost.com/v1/decide",
headers={"Authorization": f"Bearer {os.environ['LAYAHOST_API_KEY']}"},
json={
"text": "I was charged twice this month, please refund one payment.",
"template": "support_intent",
},
timeout=10,
)
res.raise_for_status()
result = res.json()
print(result["decision"], result["confidence"])
$client = new GuzzleHttp\Client(['base_uri' => 'https://layahost.com']);
$res = $client->post('/v1/decide', [
'headers' => ['Authorization' => 'Bearer ' . getenv('LAYAHOST_API_KEY')],
'json' => [
'text' => 'I was charged twice this month, please refund one payment.',
'template' => 'support_intent',
],
]);
$result = json_decode($res->getBody(), true);
echo $result['decision'], ' ', $result['confidence'], PHP_EOL;
The response names the decision, how sure the model is, and what the request cost:
{
"decision": "refund",
"confidence": 0.9902,
"probabilities": {
"refund": 0.9979,
"cancellation": 0.0006,
"other": 0.0005,
"bug_report": 0.0004,
"feature_request": 0.0003,
"question": 0.0002,
"praise": 0.0002
},
"template": "support_intent",
"model": "laya-english",
"usage": {
"decisions": 1,
"input_tokens": 91,
"cost_micros": 5,
"cost_usd": 5.0e-6
},
"latency_ms": 207.74,
"request_id": "req_iauupwcy6zdiagjozndye5ls"
}
You can also try templates and your own questions in the Playground without writing code. Playground runs are billed like API calls.
Base URL
All endpoints live under https://layahost.com/v1, with no /api prefix, exactly like the Jev API. Requests and responses are JSON, so send Content-Type: application/json with every POST.
| Method | Path | Description |
|---|---|---|
POST | /v1/decide | One decision about one text, from a template or your own question |
GET | /v1/templates | List the ready-made templates |
POST | /v1/systemone | Jev-compatible: many typed questions about one state |
GET | /v1/models | List the available models |
Next steps
- Authentication: create and use API keys.
- Migrate from Jev: switch existing Jev code in two lines.
- POST /v1/decide: the full request and response reference.
- Pricing & billing: $5 per million decisions, prepaid.