AI decisions
Use the Path SDK to classify information, score it against a rubric, or estimate whether a statement is true. Decisions run through the AI Router and use your Organization's Path credits.
Call decisions from customer-app server code. Your App needs the existing run_ai_completions permission, and the requested model must be enabled in the router catalog. Jev is available only after your environment's operator configures and enables it.
import { decide } from '@pathsystems/path/ai';
const result = await decide({
model: 'typesafe/jev',
state: { message: 'My order has not arrived' },
questions: {
department: {
type: 'choice',
instructions: 'Which team should handle this message?',
criteria: {
delivery: 'Delivery status and missing orders',
billing: 'Payments and invoices',
other: 'Other requests',
},
},
urgent: {
type: 'boolean',
instructions: 'Does the message describe an immediate deadline?',
},
severity: {
type: 'score',
instructions: 'How serious is the reported problem?',
criteria: ['Minor inconvenience', 'Blocked activity', 'Serious harm'],
},
},
});
// Inferred as 'delivery' | 'billing' | 'other'.
const department = result.answers.department.choice;
const urgencyProbability = result.answers.urgent.probability;
const severity = result.answers.severity.score;
Boolean answers return a probability from zero to one. Choice answers return the selected option, a probability for each option, and confidence. Score answers return a probability-weighted level index, its legend, probabilities, and confidence. A three-level score ranges from zero to two and may be fractional.
Confidence describes how concentrated the model's distribution is. It does not guarantee correctness. Choose thresholds using examples from your application, and keep permission checks and action execution in your application code.
Request limits
- Batch up to 64 questions in one request against the same state.
- Supply state as a JSON string, object, or array.
- Use text instructions and text rubrics. A choice description may also be
null. - Define 2–255 options per choice, or 2–10 levels per score.
- Keep the serialized request within 256 KiB and each instruction/rubric within 16,384 characters.
- Questions are independent: one answer does not become another question's input in the same batch.
Pass an AbortSignal in the second argument to cancel a request. The same argument accepts the SDK's request or userContext options for end-user attribution. Credentials remain on the server.
const result = await decide(decisionRequest, {
request: incomingRequest,
signal: incomingRequest.signal,
});
The response includes a request id, the public model slug, the exact provider_model version, and usage.input_tokens / usage.output_tokens. These counts describe provider usage; pricing comes from the Path catalog.
Errors and billing
Use asPathAIFailure() from the same module to classify router errors such as rate limits and insufficient credits. The helper does not retry automatically or substitute a chat model. Jev cannot be passed to generateText() or /chat/completions; use decide() or POST /api/v1/ai/v1/decisions.
Malformed requests and incompatible model/endpoint combinations fail before upstream inference. Usage the provider reports is retained even when answer validation fails or the caller disconnects. The router stores request size and question count for auditing, without storing the decision state, rubrics, or answers in its permanent request payload.