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

# Questions and answers

> Structure of a Krun request (context and questions) and of the answers it returns.

Every call to `POST /v1/decide` has the same shape:

```text theme={null}
context + questions  →  answers
```

* `context` is the text to decide on, such as a user message, a ticket or an agent step.
* `questions` is a map of the decisions you want about that context, keyed by ids you choose.
* `answers` has one answer per question, under the same ids, in the same order.

## Questions

```json theme={null}
{
  "context": "Customer wants to return an item.",
  "questions": {
    "department": {
      "type": "choice",
      "options": {
        "shipping": "Shipping and delivery issues",
        "returns": "Returns and refunds",
        "billing": "Billing and payment issues"
      }
    }
  }
}
```

Each question has:

| Field        | Required | Description                                                                                           |
| ------------ | -------- | ----------------------------------------------------------------------------------------------------- |
| id (the key) | Yes      | Your name for the question, like `department`. 1 to 100 characters. Returned as the key in `answers`. |
| `type`       | Yes      | Always `"choice"`: pick one option. It is the only question type today.                               |
| `options`    | Yes      | Map of option id to description, 2 to 64 options.                                                     |
| `task_type`  | No       | `"intent"` (default) or `"tool"` for [tool routing](/guides/tool-routing).                            |

### Options

Option ids are yours. Use the ids your code already understands, like `transaction_charged_twice` or `calendar_search`. Krun returns them exactly as sent, in `choice` and in `probabilities`. Option ids can be 1 to 200 characters.

The description is optional:

* **With a description**, like `"returns": "Returns and refunds"`, the model reads it to understand the option. Descriptions can be up to 1,000 characters.
* **Label-only**, with `""` or `null`, the model uses the option id alone. Use readable ids, like `lost_or_stolen_card`.

The choice between the two changes how reliable abstention is. See [Abstention status](/concepts/abstention#abstention-status).

<Note>
  Duplicate question ids or option ids, unknown fields and question types other than `choice` are rejected with `400 INVALID_REQUEST` before any inference runs.
</Note>

## Answers

```json theme={null}
{
  "model": "krun-one-v0",
  "answers": {
    "department": {
      "type": "choice",
      "choice": "returns",
      "confidence": 0.967536,
      "probabilities": {
        "shipping": 0.011351,
        "returns": 0.978886,
        "billing": 0.009763
      },
      "abstain": false,
      "abstention_status": "advisory"
    }
  },
  "usage": {
    "input_tokens": 49
  }
}
```

| Field               | Description                                                                                                            |
| ------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `type`              | `"choice"`.                                                                                                            |
| `choice`            | The selected option id, or `null` when the model abstains.                                                             |
| `confidence`        | Top-1 probability minus top-2 probability. See [Confidence and probabilities](/concepts/confidence-and-probabilities). |
| `probabilities`     | Probability per option id, in request order.                                                                           |
| `abstain`           | `true` when `confidence` is below the abstention threshold. `choice` is then `null`.                                   |
| `abstention_status` | `"calibrated"` or `"advisory"`: how much to trust `abstain`. See [Abstention](/concepts/abstention).                   |

The response also has `model`, the model that answered, and `usage.input_tokens`. See [Usage and tokens](/concepts/usage-and-tokens).

The request id is not in the body. It is in the `X-Request-ID` response header, and the Python SDK exposes it as `result.request_id`.

## Several questions per call

A request can carry up to 16 questions about the same context. They are answered together, in one model job. See [Multiple questions](/guides/multiple-questions).
