Skip to content
IntroducingSPEV, the first audio-in decision modelRead the launch →
SPEV, the first audio-in decision model →
sprag

Decisions API

Send evidence and an ordered list of predicate, choice, and score questions, and read back one typed answer per question.

POST /v1/decisions takes evidence and a list of questions and returns one answer per question, in question order.

Request

curl https://api.sprag.ai/v1/decisions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $SPRAG_API_KEY" \
  -d '{
    "model": "spev",
    "input": "The agent was polite but could not answer my question about the invoice.",
    "questions": [
      {
        "name": "resolution",
        "type": "score",
        "instructions": "How well was the issue resolved?",
        "levels": [
          { "label": "unresolved", "description": "The question was not answered." },
          { "label": "partial" },
          { "label": "resolved" }
        ]
      }
    ]
  }'
FieldRequiredTypeNotes
modelYesstringA model id from the Decisions models.
inputYesstring or arrayText evidence, or an array of user messages. See Send an image.
questionsYesarrayAt least one question, up to the model's limit. See Limits. Answers come back in this order.
input_audioNoobjectAn audio clip as {"data": "<base64>", "format": "wav"}. See Send audio.
input_videoNoobjectA visual video file as {"data": "<base64>", "format": "mp4"} when the model's catalog entry lists input_video. See Sprag extensions.
safety_identifierNostringAn opaque id for your end user, up to 128 characters.

Ask a question

Every question has a type and instructions. name is optional. If you set name, the answer carries the same name; otherwise its name is null. Names are unique within a request.

Predicate

A predicate asks whether a condition holds.

{ "name": "refund", "type": "predicate", "instructions": "Is the customer asking for a refund?" }

The answer's probability is the probability that the condition holds, from 0 to 1.

{ "type": "predicate", "name": "refund", "probability": 0.9997 }

Choice

A choice picks one value from a list you supply.

FieldRequiredTypeNotes
choicesYesarray2 to 255 options. Each value is a string or a boolean, and values are distinct.
choices[].descriptionNostringWhen this option applies.

The answer's choice is the selected value, with the same type you sent. probabilities holds one entry per option in the order you supplied them, and confidence runs from 0 to 1.

{
  "type": "choice",
  "name": "department",
  "choice": "billing",
  "probabilities": [
    { "value": "billing", "probability": 0.981 },
    { "value": "technical", "probability": 0.019 }
  ],
  "confidence": 0.962
}

Score

A score rates the evidence on a scale of levels you define, lowest first.

FieldRequiredTypeNotes
levelsYesarray2 to 10 levels in ascending order. The first level has the value 0.
levels[].labelYesstringThe level's name.
levels[].descriptionNostringThe criteria for this level.

probabilities holds one entry per level, with its value and label. score is the expected level value: each level's value weighted by its probability. A score of 1.5 on a three-level scale sits halfway between the second and third levels. confidence runs from 0 to 1.

{
  "type": "score",
  "name": "resolution",
  "score": 0.0073,
  "probabilities": [
    { "value": 0, "label": "unresolved", "probability": 0.993 },
    { "value": 1, "label": "partial", "probability": 0.0067 },
    { "value": 2, "label": "resolved", "probability": 0.0003 }
  ],
  "confidence": 0.989
}

Refusal

An answer of type refusal can replace the answer to any question. It carries the question's name and no probabilities.

{ "type": "refusal", "name": "resolution" }

Send an image

To attach an image, send input as an array of user messages. Each message's content is a string or an array of input_text and input_image parts.

{
  "model": "spev",
  "input": [
    {
      "role": "user",
      "content": [
        { "type": "input_text", "text": "Photo from the delivery driver." },
        { "type": "input_image", "image_url": "data:image/png;base64,iVBORw0KGgo..." }
      ]
    }
  ],
  "questions": [
    {
      "type": "predicate",
      "instructions": "Does the photo show a package at a door?"
    }
  ]
}
FieldRequiredTypeNotes
roleYesstringuser.
contentYesstring or arrayText, or an array of parts.
input_image.image_urlYesstringAn image data: URL or a public HTTP(S) URL, subject to model support.
input_image.detailNostringlow, high, auto, or original.

SPEV accepts one inline data:image/...;base64,... image per request. Its detail is auto or omitted.

Send audio

To attach audio, send the clip as input_audio next to input.

{
  "model": "spev",
  "input": "Call recording attached.",
  "input_audio": { "data": "UklGRiQAAABXQVZF...", "format": "wav" },
  "questions": [
    { "type": "predicate", "instructions": "Does the caller ask to cancel?" }
  ]
}

input_audio.data is the base64-encoded file, not a data: URL. input_audio.format is a nonempty, free-form container or format hint, such as wav or mp3. For video evidence and media token usage, see Sprag extensions.

Limits

Each model limits the questions, images, and context a request may carry. If a request exceeds a limit, it returns HTTP 400 with the error code model_limit_exceeded. The error message states the limit. param names the field over its limit, questions or input, and is null when the request exceeds the context.

Response

FieldTypeNotes
modelstringThe model id from the request.
answersarrayOne answer per question, in question order.
usage.input_tokensintegerTotal input tokens, including text and media evidence.
usage.input_tokens_details.cached_tokensintegerInput tokens read from cache.
usage.input_tokens_details.cache_write_tokensintegerInput tokens written to cache.
usage.input_tokens_details.multimodal_tokensobject or nullNative input token counts keyed by audio, image, or video, when supplied. Absent modalities have no key.
usage.output_tokensintegerOutput tokens.
usage.output_tokens_details.reasoning_tokensintegerReasoning output tokens.
usage.total_tokensintegerInput and output tokens together.

Decisions has no streaming mode. The response arrives once every question has an answer.

Errors

StatusMeaning
400Validation error, such as a duplicate question name, duplicate choice values, or fewer than two levels. Also sent with the code model_limit_exceeded when the request exceeds a model limit. See Limits.
401Missing, invalid, or expired credentials.
402Out of credit. Also sent with the code payment_overdue when a plan invoice is unpaid. Also sent while billing for a new account is being set up; retry the request after a moment.
403Not a member of the requested organization.
404Unknown model id.
413Request too large.
429Rate limit exceeded.
502The model returned an error. Also sent when the model's answers do not match the questions. Retry the request.
503Temporarily unavailable. Retry after Retry-After when it is set.

POST /v1/systemone is retired. A request to it returns HTTP 410 with the error code endpoint_removed.

See the errors reference for the full error shape and retry guidance.