
The bundled `ai` library provides the context behind `ai using`, `feels`,
`match ... by meaning`, and `llm`. A context holds the model capabilities a
workflow may use and the limits shared by its calls. See
[Semantic AI control flow](/docs/ai-semantic-control-flow/) for the syntax and
[Native AI evals](/docs/ai-evals/) for measuring results.

| Capability | What it does | Bundled adapter |
| --- | --- | --- |
| Judge | Answers a yes/no question, with an uncertain outcome | TypeSafe |
| Router | Chooses among descriptions, or abstains | TypeSafe |
| Generator | Produces text from instructions and input | Chat Completions |

An adapter connects a capability to a provider protocol. The workflow uses
the capability, so changing a compatible provider does not change its Vary
code. The model name alone does not determine which capabilities are available.

## Create a context

The support-triage example gets a Judge and Router from the TypeSafe adapter,
then gives them one budget:

```vary-snippet
from ai.decision_context import decision_context
from ai.adapters.typesafe.decisions import decisions as typesafe_decisions
from ai.context import AiContext
from ai.types import AiError

def live_context(key: Str, model: Str, endpoint: Str) -> Result[AiContext, AiError] {
    let provider = typesafe_decisions(key, model, endpoint, 3)?
    return decision_context(provider, 2, 10000)
}
```

Here, `2` limits the whole workflow to two attempts and `10000` sets a
ten-second deadline. Helpers receiving the same context share those limits;
retries spend attempts too. Before a model call, `ai using` checks that the
context has every capability its block needs.

`DecisionSettings` with `configured_decision_context` lets you change request
timeouts, judgment and routing thresholds, and loop limits. The default
judgment threshold is 0.8; routing probability and confidence thresholds are
0.75 and 0.65. The default request timeout is ten seconds, capped by the
remaining workflow deadline.

Failures, uncertainty, and exhausted budgets have distinct typed outcomes.
Traces record attempts and model identity; raw content is recorded only when
enabled. For runnable offline and live setups, see the
[support-triage example](/articles/jev-ai-with-vary/).
