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

# Capability rules

> The capability rules that map a provider and model to what it accepts: token-limit parameter, reasoning, modalities, JSON mode and supported parameters.

Nika's capability system answers one question: **given a `provider + model`,
what does it accept?** Which parameter carries the token limit? Is it a
reasoning model? Vision input? JSON schema mode? A temperature?

The answer is a `ModelCapabilities` value, computed at runtime from
**57 rules** and a defaults block. The first rule that
matches wins. Zero regex, zero allocation, zero runtime dependencies.

> [!NOTE]
>
> **Canonical source:** [`crates/nika-catalog/data/model-capabilities.toml` at v0.123.0](https://github.com/supernovae-st/nika/blob/v0.123.0/crates/nika-catalog/data/model-capabilities.toml).
> Schema: `nika/model-capabilities@1.0`. The build checks every rule against
> `llm-providers.toml` (an unknown provider fails the build, so a typo cannot
> ship) and requires every `any` rule to come last within its provider scope.

## Resolution algorithm

**1. Scan `[[rules]]` in file order**

A rule whose `scope.providers` list does not name the provider is
skipped, and so is one whose `scope.api_dialect` does not match the
provider's dialect.

**2. The first match wins**

The first rule whose `match` clause matches the model name supplies its
`caps`, and the scan stops. Order is load-bearing: a narrow rule must come
before a broader one that would also match (`o4` before `o4-`, `gpt-4o`
before `gpt-4`).

**3. Fill the rest from `[defaults]`**

Every field the winning rule does not set comes from the defaults block:

```toml theme={"system"}
[defaults]
token_limit_param        = "max-tokens"
supports_temperature     = true
supports_stop_sequences  = true
reasoning                = false
input_modalities         = ["text", "image"]
output_modalities        = ["text"]
supported_parameters     = []
supports_system_messages = true
reasoning_efforts        = []
```

## The four match kinds

> [accordion] `any`: matches every model of the scope
>
> ```toml theme={"system"}
> [[rules]]
> name  = "mock-full"
> scope = { providers = ["mock"] }
> match = { kind = "any" }
> caps  = { reasoning = true, tokenizer = "cl100k", input_modalities = ["audio", "image", "pdf", "text", "video"], output_modalities = ["text"], supported_parameters = ["batch-api", "citations", "computer-use", "context-caching", "file-search", "include-reasoning", "parallel-tool-calls", "predicted-outputs", "prompt-caching", "reasoning-effort", "streaming-thinking", "thinking-budget", "web-search"], supports_system_messages = true, json_mode = "schema" }
> ```
>
> A provider-wide fallback. It must be the last rule of its scope.

> [accordion] `exact`: matches one model id
>
> ```toml theme={"system"}
> [[rules]]
> name  = "deepseek-reasoner"
> scope = { providers = ["deepseek"] }
> match = { kind = "exact", model = "deepseek-reasoner" }
> caps  = { supports_temperature = false, reasoning = true, tokenizer = "deepseek", input_modalities = ["text"], output_modalities = ["text"], supported_parameters = [], json_mode = "object" }
> ```
>
> A per-model override that deviates from its family.

> [accordion] `exact_any`: matches a set of model ids
>
> ```toml theme={"system"}
> [[rules]]
> name  = "openai-o-series-exact"
> scope = { providers = ["openai", "openrouter"] }
> match = { kind = "exact_any", models = ["o1", "o3", "o4"] }
> caps  = { token_limit_param = "max-completion-tokens", supports_temperature = false, reasoning = true, tokenizer = "o200k", input_modalities = ["image", "text"], output_modalities = ["text"], supported_parameters = ["reasoning-effort"], supports_system_messages = false, json_mode = "schema" }
> ```
>
> An explicit list when the ids share no prefix.

> [accordion] `prefix_any`: matches ids that start with a prefix
>
> ```toml theme={"system"}
> [[rules]]
> name  = "openai-gpt5-family"
> scope = { providers = ["openai", "openrouter"] }
> match = { kind = "prefix_any", prefixes = ["gpt-5-", "gpt-5."] }
> caps  = { token_limit_param = "max-completion-tokens", reasoning = true, tokenizer = "o200k", input_modalities = ["image", "text"], output_modalities = ["text"], supported_parameters = ["parallel-tool-calls"], json_mode = "schema" }
> ```
>
> The most common kind: one rule covers a model family. Prefix match only,
> no regex.

## Capability fields

What a rule can set:

| Field | Type | Example |
| - | - | - |
| `token_limit_param` | enum | `max-tokens` · `max-completion-tokens` · `max-output-tokens`: the request parameter that carries `max_tokens` |
| `supports_temperature` | bool | `false` for models that reject a temperature: `nika check` then refuses a `temperature:` on them, on Anthropic's API and on the `openai` provider for `gpt-5`, `gpt-5-mini`, `gpt-5-nano` and the o-series, instead of letting the provider answer HTTP 400 at run. Dated snapshot ids, `gpt-5.1` onward and OpenRouter routes are not covered yet ([Known limits](https://docs.nika.sh/changelog/known-limits.md#smaller-differences)) |
| `supports_stop_sequences` | bool | `false` for models that reject stop sequences |
| `supports_system_messages` | bool | `false` sends the system text as a developer message |
| `reasoning` | bool | `true` for a reasoning model, whose thinking counts against its output cap |
| `reasoning_efforts` | string\[] | the efforts the model accepts, for example `["low", "high", "max"]` |
| `reasoning_facts` | table | how thinking behaves: `by_default`, `in_output_cap`, `off` (`never` · `not-reached` · `by-default` · `budget-zero`) |
| `tokenizer` | string | the tokenizer family used for estimates (`o200k`, `claude-v3`, `gemini` …) |
| `input_modalities` | string\[] | `["text", "image", "audio", "pdf"]` |
| `output_modalities` | string\[] | `["text"]` · `["speech"]` · `["image-gen"]` |
| `json_mode` | enum | `unavailable` · `object` · `schema` |
| `supported_parameters` | string\[] | see below |

### Supported parameter vocabulary (13)

> [!TIP]
>
> The vocabulary is **closed**: adding a new parameter is a `nika-catalog` schema change.

| Parameter | Meaning |
| - | - |
| `parallel-tool-calls` | Multiple tools invoked in one step |
| `reasoning-effort` | A reasoning effort level the request can set |
| `thinking-budget` | An extended thinking budget in tokens |
| `prompt-caching` | Prompt caching (cache-control blocks) |
| `file-search` | A provider-side file search tool |
| `web-search` | A provider-side web search tool |
| `streaming-thinking` | Reasoning tokens streamed separately |
| `batch-api` | Batch mode |
| `context-caching` | Context caching |
| `predicted-outputs` | Predicted outputs |
| `computer-use` | A provider computer-use tool |
| `citations` | Citations in the answer |
| `include-reasoning` | The `include-reasoning` flag |

### Modality vocabulary (8)

`text` · `image` · `audio` · `video` · `pdf` · `embedding` · `speech` · `image-gen`

> [!WARNING]
>
> `input_modalities` **must** contain `text` (build invariant). A pure-image
> input model can't be wired as an `infer:` target without text support.

## Example resolution

```toml rules (excerpt, in file order) theme={"system"}
[[rules]]
name  = "claude-5-always-thinking-on-anthropic"
scope = { providers = ["anthropic"] }
match = { kind = "exact_any", models = ["claude-fable-5-1", "claude-fable-5", "claude-opus-5-5"] }
caps  = { supports_temperature = false, reasoning = true, tokenizer = "claude-v3", input_modalities = ["image", "pdf", "text"], output_modalities = ["text"], supported_parameters = ["prompt-caching", "reasoning-effort", "streaming-thinking"], json_mode = "schema", reasoning_efforts = ["low", "high", "max"], reasoning_facts = { by_default = true, in_output_cap = true, off = "never" } }

[[rules]]
name  = "claude-5-adaptive-thinking-on-anthropic"
scope = { providers = ["anthropic"] }
match = { kind = "exact_any", models = ["claude-sonnet-5-5", "claude-haiku-5-5", "claude-opus-5", "claude-sonnet-5"] }
caps  = { supports_temperature = false, reasoning = true, tokenizer = "claude-v3", input_modalities = ["image", "pdf", "text"], output_modalities = ["text"], supported_parameters = ["prompt-caching", "reasoning-effort", "streaming-thinking"], json_mode = "schema", reasoning_efforts = ["low", "high", "max"], reasoning_facts = { by_default = true, in_output_cap = true, off = "not-reached" } }

[[rules]]
name  = "claude-on-anthropic"
scope = { providers = ["anthropic"] }
match = { kind = "prefix_any", prefixes = ["claude"] }
caps  = { reasoning = true, tokenizer = "claude-v3", input_modalities = ["image", "pdf", "text"], output_modalities = ["text"], supported_parameters = ["prompt-caching", "streaming-thinking", "thinking-budget"], json_mode = "schema", reasoning_facts = { by_default = false, in_output_cap = true, off = "by-default" } }
```

```text Resolved (anthropic, claude-sonnet-5-5) theme={"system"}
rule 1   claude-5-always-thinking-on-anthropic     no match
rule 2   claude-5-adaptive-thinking-on-anthropic   match: the scan stops
         (claude-on-anthropic would also match, but it is never reached)

supports_temperature     false                    rule 2
reasoning                true                     rule 2
reasoning_efforts        low · high · max         rule 2
input_modalities         image · pdf · text       rule 2
json_mode                schema                   rule 2
supported_parameters     prompt-caching · reasoning-effort · streaming-thinking
token_limit_param        max-tokens               defaults
supports_stop_sequences  true                     defaults
supports_system_messages true                     defaults
```

## Why not regex

> [!NOTE]
>
> L0 crates ship zero runtime dependencies beyond `std` + `alloc`. Regex
> would pull in `regex-automata` (\~50k LOC) and force a runtime
> initialization cost. `prefix_any` covers 95% of actual model-family
> matching needs; the remaining 5% is handled by `exact_any`.

This is Q1 (no proc macros) applied at the data-layer. See
[L0 foundation decisions](https://docs.nika.sh/architecture/l0-decisions.md).

## How to query capabilities

Two shipped subcommands project the embedded catalogs — `nika catalog`
(providers · models · capabilities · env vars) and `nika catalog --tools` (the
`nika:*` builtin schemas), each with a versioned `--json` machine form:

```bash nika catalog (shipped) theme={"system"}
$ nika catalog                # human listing · local providers first
$ nika catalog --json         # machine projection (catalog_version: 1)
$ nika catalog --tools --json # builtin tool catalog (tools_version: 1)
```

```rust Rust API (nika-catalog) theme={"system"}
use nika_catalog::model_capabilities;

let caps = model_capabilities("anthropic", "claude-sonnet-5-5");
assert!(caps.reasoning);               // a thinking model: thinking counts against max_tokens
assert!(!caps.supports_temperature);   // the request omits temperature
// also: token_limit_param · input_modalities · output_modalities · json_mode ·
// supported_parameters · reasoning_efforts · reasoning_facts · tokenizer
```

## Drift protection

> [!TIP]
>
> **Build-time FK check:** every `scope.providers[i]` must be a canonical
> provider id in `llm-providers.toml`. Typos fail the build.
>
> **Build-time enum check:** every `supported_parameters` entry must be in
> the 13-value vocabulary. New additions require a schema bump.
>
> **Build-time ordering check:** `tags` arrays in `llm-providers.toml` must
> be sorted + deduplicated. Same applies to `caps.*` arrays by convention.

## See also

> [card] [Providers catalog](https://docs.nika.sh/reference/providers-catalog.md)
>
> The 18 canonical providers these rules target.

> [card] [Concepts · Providers](https://docs.nika.sh/concepts/providers.md)
>
> Model and access, the wires, structured output.

> [card] [Schema](https://docs.nika.sh/reference/schema.md)
>
> `.nika` envelope + workflow schema reference.

> [card] [L0 decisions](https://docs.nika.sh/architecture/l0-decisions.md)
>
> Q1-Q13: why no regex, why manual impl, why prefix-only matching.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.