Skip to main content
Evaluates text against named questions and returns a typed answer for each question. For a complete request and example results, see Decision models.

Request body

string
required
The Model API slug. Use decision-models/laya for Laya.
string
required
The text to evaluate. Serialize structured records to a string before sending them. Laya rejects a JSON object in this field with HTTP 422.
object
required
A map of question names to question definitions. The response uses the same names in answers.

Question definitions

Each question contains type and instructions. The criteria format depends on its type.
string
required
One of choice, noul, or score.
string
required
The question to evaluate against state.
object | string[]
Required for choice and score. For choice, provide an object mapping option names to descriptions. For score, provide an array of descriptions ordered from the lowest level to the highest. A noul question can omit this field.
Questions

Response body

string
The backend model identifier. This can differ from the Model API slug in the request.
object
A map of question names to typed answers. Each answer includes its type and the fields described below. Responses can include additional model-specific fields.
integer
The number of input tokens used by the request.
integer
0 for Laya decision requests.

Answer fields

These fields appear inside each named entry in answers.
string
The question type: choice, noul, or score.
object
For choice, each option’s name mapped to its probability. For score, each zero-based level number, represented as a string key, mapped to its probability.

Choice answers

string
The selected option’s name.

Yes/no answers

number
The probability of yes, from 0 to 1. Apply a threshold in your application to make a yes/no decision.

Score answers

number
The score on the rubric. It can fall between levels.
object
Level numbers, represented as string keys starting at 0, mapped to their descriptions.

Errors

HTTP 422 indicates an invalid request, such as a missing questions field, an object instead of a string in state, or an unsupported question type. The JSON response includes an error message describing the problem.
Invalid question type