Decisions
Ask typed questions about text, audio, or an image and get each answer back with its probabilities.
Decisions lets you ask typed questions about a piece of evidence and get each answer back with its probabilities. You send the evidence once, then a list of questions, and the response carries one answer per question in the same order.
| Question type | Answers with |
|---|---|
predicate | The probability that a condition holds |
choice | One of the values you supply, with a probability for each |
score | A rating on a scale of levels you define, with a probability for each level |
Use Decisions when your code acts on the answer: routing a ticket, flagging a call, grading a response against a rubric.
Get an API key
Create a Sprag account and open API keys in the app to generate one.
Copy the key immediately. The full value is shown once and is not recoverable after you leave the page.
Export it as an environment variable, replacing the placeholder with your key:
export SPRAG_API_KEY=<your_sprag_api_key>Make a request
Send the evidence in input and the questions in questions.
curl https://api.sprag.ai/v1/decisions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $SPRAG_API_KEY" \
-d '{
"model": "spev",
"input": "I was charged twice. Please refund the duplicate payment.",
"questions": [
{
"name": "department",
"type": "choice",
"instructions": "Which team should handle this?",
"choices": [{ "value": "billing" }, { "value": "technical" }]
},
{
"name": "refund",
"type": "predicate",
"instructions": "Is the customer asking for a refund?"
}
]
}'Read the answers
Each answer carries its question's type and name, in question order.
{
"model": "spev",
"answers": [
{
"type": "choice",
"name": "department",
"choice": "billing",
"probabilities": [
{ "value": "billing", "probability": 0.981 },
{ "value": "technical", "probability": 0.019 }
],
"confidence": 0.962
},
{
"type": "predicate",
"name": "refund",
"probability": 0.9997
}
],
"usage": {
"input_tokens": 221,
"input_tokens_details": { "cached_tokens": 0 },
"output_tokens": 0,
"total_tokens": 221
}
}To act on a choice, read choice. To set your own threshold, read the
probabilities instead.
Where to go next
API. Look up the question types, the evidence formats, and the errors.
Models. See which models answer Decisions requests and what evidence each one accepts.