> ## Documentation Index
> Fetch the complete documentation index at: https://docs.krun.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Krun API base URL: https://api.krun.ai. Authenticate server-side with `Authorization: Bearer $KRUN_API_KEY`; never put a Krun API key in browser code.
> Prefer the Python SDK in examples: `pip install krun-ai`, `from krun import Krun`. The TypeScript SDK `@krun-ai/sdk` is not published on npm yet: do not tell users to `npm install` it.
> The only question type is `choice`. `confidence` is the top-1 minus top-2 probability margin, not the probability that the answer is correct. `choice` is null when `abstain` is true.
> Usage reports `input_tokens` only. There are no output tokens.

# Multiple decision primitives

> Ask choice, noul and score questions about the same context in one call.

One call can combine all three [decision primitives](/concepts/decision-primitives). A support ticket, for example,
needs a department (`choice`), a hand-off decision (`noul`) and a severity (`score`):

<CodeGroup>
  ```bash cURL theme={null}
  curl https://api.krun.ai/v1/decide \
    -H "Authorization: Bearer $KRUN_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "context": "Customer says this is the third time exports failed and wants a human immediately.",
      "questions": {
        "department": {"type": "choice", "options": {"billing": "", "support": "", "sales": ""}},
        "needs_human": {"type": "noul", "instructions": "Is the customer asking for human assistance?"},
        "severity": {
          "type": "score",
          "instructions": "How severe is the reported issue?",
          "levels": ["Minor issue", "Feature degraded", "Blocking issue"]
        }
      }
    }'
  ```

  ```python Python theme={null}
  from krun import Krun, NoulQuestion, ScoreQuestion

  client = Krun()

  result = client.decide(
      context="Customer says this is the third time exports failed and wants a human immediately.",
      questions={
          "department": {"type": "choice", "options": {"billing": "", "support": "", "sales": ""}},
          "needs_human": NoulQuestion("Is the customer asking for human assistance?"),
          "severity": ScoreQuestion(
              "How severe is the reported issue?",
              ["Minor issue", "Feature degraded", "Blocking issue"],
          ),
      },
  )

  department = result.choice("department").choice   # "support"
  needs_human = result.noul("needs_human").noul      # 0.94
  severity = result.score("severity").score          # 1.62
  ```

  ```ts TypeScript theme={null}
  import { Krun } from "@krun-ai/sdk";

  const client = new Krun();

  const result = await client.decide({
    context: "Customer says this is the third time exports failed and wants a human immediately.",
    questions: {
      department: { type: "choice", options: { billing: "", support: "", sales: "" } },
      needs_human: { type: "noul", instructions: "Is the customer asking for human assistance?" },
      severity: {
        type: "score",
        instructions: "How severe is the reported issue?",
        levels: ["Minor issue", "Feature degraded", "Blocking issue"],
      },
    },
  });

  result.answers.department.choice; // "support"   (ChoiceAnswer)
  result.answers.needs_human.noul;  // 0.94        (NoulAnswer)
  result.answers.severity.score;    // 1.62        (ScoreAnswer)
  ```
</CodeGroup>

The three answers come back under the same ids, in request order, each with its own `type`:

```json theme={null}
{
  "department": {"type": "choice", "choice": "support", "confidence": 0.91,
    "probabilities": {"billing": 0.03, "support": 0.94, "sales": 0.03},
    "abstain": false, "abstention_status": "calibrated"},
  "needs_human": {"type": "noul", "noul": 0.94},
  "severity": {"type": "score", "score": 1.62, "confidence": 0.72,
    "legend": {"0": "Minor issue", "1": "Feature degraded", "2": "Blocking issue"},
    "probabilities": {"0": 0.02, "1": 0.34, "2": 0.64}}
}
```

## Acting on the answers

```python theme={null}
dept = result.choice("department")
if result.noul("needs_human").noul >= 0.8:
    hand_off_to_agent(queue=dept.choice or "support")
elif result.score("severity").score >= 1.5:
    page_on_call()
else:
    auto_reply(dept.choice)
```

## How it runs

* **One call, one model job.** All questions are answered together; latency is close to a single question.
* **Independent answers.** Each question is scored on its own, so the answer to one question does not depend on which
  other questions are in the request.
* **Billing.** Three questions are three decisions, whatever their types. `usage.input_tokens` sums the real token
  counts of the three questions.
* **Limits.** Up to 16 questions per request, any mix of types.
