> ## 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.

# Score

> Rate the context on ordered levels: an expected level plus a probability for each level.

A `score` question rates the context on **ordered semantic levels**, lowest first. Krun returns a probability
distribution over the levels and the **expected score**.

## Complete example

<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": "Production is down: nobody can log in and there is no workaround.",
      "questions": {
        "severity": {
          "type": "score",
          "instructions": "How severe is the reported issue?",
          "levels": [
            "Cosmetic issue; no functionality affected",
            "Feature degraded; workaround available",
            "Critical functionality blocked; no workaround"
          ]
        }
      }
    }'
  ```

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

  client = Krun()  # reads KRUN_API_KEY

  result = client.decide(
      context="Production is down: nobody can log in and there is no workaround.",
      questions={
          "severity": ScoreQuestion(
              "How severe is the reported issue?",
              [
                  "Cosmetic issue; no functionality affected",
                  "Feature degraded; workaround available",
                  "Critical functionality blocked; no workaround",
              ],
          ),
      },
  )

  severity = result.score("severity")
  print(severity.score)          # 1.88
  print(severity.probabilities)  # {"0": 0.005, "1": 0.107, "2": 0.887}
  ```
</CodeGroup>

Response:

```json theme={null}
{
  "model": "krun-one-v0.3",
  "answers": {
    "severity": {
      "type": "score",
      "score": 1.881956,
      "confidence": 0.885152,
      "legend": {
        "0": "Cosmetic issue; no functionality affected",
        "1": "Feature degraded; workaround available",
        "2": "Critical functionality blocked; no workaround"
      },
      "probabilities": {"0": 0.005369, "1": 0.107306, "2": 0.887325}
    }
  },
  "usage": {
    "input_tokens": 59
  }
}
```

The body always has a `context` and a `questions` map keyed by ids you choose (`severity` here); the answer comes back
under the same id. A request can mix `score` questions with [`choice`](/concepts/primitives/choice) and
[`noul`](/concepts/primitives/noul) questions, up to 16.

## Expected score

The score is the expected level index under the distribution, **not** the most likely level:

```text theme={null}
score = Σ (index × probability)
      = 0 × 0.00 + 1 × 0.57 + 2 × 0.43 = 1.43
```

It lies between `0` and `levels − 1`. With a distribution like `{"0": 0.0, "1": 0.57, "2": 0.43}`, the score is 1.43: "between degraded and critical, closer to degraded", which
you can threshold, average across tickets or sort by. If you need a single level, use the most likely one from
`probabilities`, or round the score.

## Fields

| Field           | Description                                                  |
| --------------- | ------------------------------------------------------------ |
| `score`         | Expected level, in \[0, levels − 1].                         |
| `probabilities` | Level index (`"0"`, `"1"`, …) → probability, in level order. |
| `legend`        | Level index → the level text you sent.                       |
| `confidence`    | How concentrated the distribution is, in \[0, 1].            |

`confidence` is `1 − Var / Varmax`, where `Var` is the variance of the level index under `probabilities` and
`Varmax = ((levels − 1) / 2)²` is the largest variance possible. It is `1` when all probability is on one level and `0`
when it is split between the lowest and the highest level. It measures how sure the model is **about the score**, so a
distribution split between two neighbouring levels has higher confidence than one split between the extremes.

## Question fields

A `score` question is one entry of `questions`:

| Field          | Required | Description                                                       |
| -------------- | -------- | ----------------------------------------------------------------- |
| `type`         | Yes      | `"score"`                                                         |
| `instructions` | Yes      | What to rate (1–1,000 characters).                                |
| `levels`       | Yes      | 2 to 16 level descriptions, lowest first (1–500 characters each). |

## Levels

| Rule             |                                                                                |
| ---------------- | ------------------------------------------------------------------------------ |
| 2 to 16 levels   | Each 1–500 characters.                                                         |
| Lowest first     | Index `0` is the lowest level.                                                 |
| Order is meaning | Krun never reorders levels. Changing their order changes what the score means. |

Write levels as descriptions, not bare numbers. In a request:

```json theme={null}
{
  "context": "The export button is slow but the file still downloads.",
  "questions": {
    "severity": {
      "type": "score",
      "instructions": "How severe is the reported issue?",
      "levels": ["Minor issue", "Feature degraded", "Blocking issue"]
    }
  }
}
```

is much better than `["0", "1", "2"]` or `["low", "medium", "high"]` with no context: the model reads the level text.

<Note>
  Krun One was trained and evaluated on 5-level scales (response quality, harm severity, sentiment). Other level
  counts work the same way, but have been validated less.
</Note>

Send corrections with [feedback](/guides/feedback): `expected: {"type": "score", "value": 2}` (the correct level
index).
