---
title: Make a decision
description: Ask yes/no, choice, and score questions about text, and get typed answers with probabilities.
---

SubQ Snap answers questions about a `state` (text, an object, or an array) and
returns typed answers with probabilities your code can act on: route a ticket,
gate an action, rate how urgent something is. To generate text instead, see
[Generate text](/using-the-api/generate-text/).

## Pick a question type

| Type     | Asks                              | Answer                                                                         |
| -------- | --------------------------------- | ------------------------------------------------------------------------------ |
| `noul`   | A yes/no gate.                    | `noul`, the probability of yes from `0` to `1`.                                |
| `choice` | Which one of 2–255 named options. | `choice`, a probability for every option, and `confidence`.                    |
| `score`  | A rating on 2–10 ordered levels.  | `score`, which can fall between levels, plus `probabilities` and `confidence`. |

## Example

A clinic's patient chat gets one message. Three questions decide what happens
next: does a nurse need to see it, which team owns it, and how soon someone
should reply.

```bash title="cURL"
curl --request POST \
  --url https://api.subq.ai/v1/systemone \
  --header "Authorization: Bearer $SUBQ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data @- <<'EOF'
{
  "model": "subq-snap-1.2",
  "state": "Patient with asthma reports a sore throat, fever since yesterday, and shortness of breath walking to the kitchen this morning.",
  "questions": {
    "escalate": {
      "type": "noul",
      "instructions": "Should a nurse see this chat before the patient books anything?",
      "criteria": {
        "true": "Breathing trouble, chest pain, or a flare of a known condition",
        "false": "Stable symptoms the patient can book for themselves"
      }
    },
    "queue": {
      "type": "choice",
      "instructions": "Which team should own this chat?",
      "criteria": {
        "nurse_line": "Needs a nurse to assess symptoms today",
        "primary_care": "Book with the patient's own doctor",
        "pharmacy": "Refill or medication question only",
        "front_desk": null
      }
    },
    "acuity": {
      "type": "score",
      "instructions": "How soon should someone respond?",
      "criteria": [
        "Within a week",
        "Within a day",
        "Within an hour"
      ]
    }
  }
}
EOF
```

```ts title="TypeScript"
const baseURL = "https://api.subq.ai/v1";

// The text to judge.
const state =
  "Patient with asthma reports a sore throat, fever since yesterday, and shortness of breath walking to the kitchen this morning.";

// One question per judgment: a yes/no gate, an owning team, a response time.
const questions = {
  escalate: {
    type: "noul",
    instructions: "Should a nurse see this chat before the patient books anything?",
    criteria: {
      true: "Breathing trouble, chest pain, or a flare of a known condition",
      false: "Stable symptoms the patient can book for themselves",
    },
  },
  queue: {
    type: "choice",
    instructions: "Which team should own this chat?",
    criteria: {
      nurse_line: "Needs a nurse to assess symptoms today",
      primary_care: "Book with the patient's own doctor",
      pharmacy: "Refill or medication question only",
      front_desk: null,
    },
  },
  acuity: {
    type: "score",
    instructions: "How soon should someone respond?",
    criteria: ["Within a week", "Within a day", "Within an hour"],
  },
};

const response = await fetch(`${baseURL}/systemone`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SUBQ_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "subq-snap-1.2",
    state,
    questions,
  }),
});

if (!response.ok) {
  const error = await response.json();
  throw new Error(
    `${response.status} ${error.detail.error_type}: ${error.detail.message}`,
  );
}

const result = await response.json();
const { escalate, queue, acuity } = result.answers;

// Your code decides what happens next. Unsure routing goes to a nurse,
// and so does anything the gate says needs one.
let owner = queue.confidence >= 0.6 ? queue.choice : "nurse_line";
if (escalate.noul >= 0.5) owner = "nurse_line";

const respondWithin = acuity.legend[String(Math.round(acuity.score))];

console.log(`Escalate: ${escalate.noul.toFixed(2)}`);
console.log(
  `Owner:    ${owner} (model picked ${queue.choice}, confidence ${queue.confidence.toFixed(2)})`,
);
console.log(`Respond:  ${respondWithin}`);
```

```py title="Python"
import os

import httpx2  # pip install httpx2

base_url = "https://api.subq.ai/v1"

# The text to judge.
state = (
    "Patient with asthma reports a sore throat, fever since yesterday, and "
    "shortness of breath walking to the kitchen this morning."
)

# One question per judgment: a yes/no gate, an owning team, a response time.
questions = {
    "escalate": {
        "type": "noul",
        "instructions": (
            "Should a nurse see this chat before the patient books anything?"
        ),
        "criteria": {
            "true": (
                "Breathing trouble, chest pain, or a flare of a known condition"
            ),
            "false": "Stable symptoms the patient can book for themselves",
        },
    },
    "queue": {
        "type": "choice",
        "instructions": "Which team should own this chat?",
        "criteria": {
            "nurse_line": "Needs a nurse to assess symptoms today",
            "primary_care": "Book with the patient's own doctor",
            "pharmacy": "Refill or medication question only",
            "front_desk": None,
        },
    },
    "acuity": {
        "type": "score",
        "instructions": "How soon should someone respond?",
        "criteria": ["Within a week", "Within a day", "Within an hour"],
    },
}

response = httpx2.post(
    f"{base_url}/systemone",
    headers={"Authorization": f"Bearer {os.environ['SUBQ_API_KEY']}"},
    json={
        "model": "subq-snap-1.2",
        "state": state,
        "questions": questions,
    },
    timeout=60,
)
result = response.json()
if response.is_error:
    detail = result["detail"]
    raise RuntimeError(
        f"{response.status_code} {detail['error_type']}: {detail['message']}"
    )

answers = result["answers"]
escalate = answers["escalate"]["noul"]
queue = answers["queue"]
acuity = answers["acuity"]

# Your code decides what happens next. Unsure routing goes to a nurse,
# and so does anything the gate says needs one.
owner = queue["choice"] if queue["confidence"] >= 0.6 else "nurse_line"
if escalate >= 0.5:
    owner = "nurse_line"

respond_within = acuity["legend"][str(round(acuity["score"]))]

print(f"Escalate: {escalate:.2f}")
print(
    f"Owner:    {owner} "
    f"(model picked {queue['choice']}, confidence {queue['confidence']:.2f})"
)
print(f"Respond:  {respond_within}")
```

Read each answer by its question name:

- `answers.escalate.noul` is `0.92`, so a nurse sees the chat.
- `answers.queue.choice` is `"nurse_line"`.
- `answers.acuity.score` is `1.86`, close to "Within an hour".

See [Response](/endpoints/decisions-api/#response) for the full shape.

## Build reliable decision workflows

Keep your code in charge. Rules you can write down belong in code. Ask the
model only for the judgment code can't make, then let code decide what happens
next.

- **One judgment per question.** Split a broad question into narrow ones, like
  the gate, owner, and deadline above. Code then combines the answers.
- **Ask related questions together.** Questions about the same `state` go in
  one request, so the state is sent once.
- **Send only what the decision needs.** Trim `state` to the relevant fields,
  and name the field an instruction is about.
- **Set thresholds from your own data.** Run the questions over cases you've
  already labeled and choose cutoffs from the results.
- **Send uncertain or high-impact cases to a person.** Outputs can vary between
  requests, so route low `confidence`, a noul near `0.5`, or a costly mistake
  to review.
- **Retry `429` and `5xx` with backoff.** Fix a `400` or `422` before resending;
  a retry won't change it.

## Next steps

- [Documents and images](/using-the-api/documents-and-images/): ask about a
  document's text or up to 4 images.
- [Decisions API](/endpoints/decisions-api/): every field, limit, and error.
