# keryn ai

Describes Keryn 0.5.2 and keryn-rules 0.8.0.

> model-proposed triage, summary, threat model, exception drafts, ship-or-hold advice; nothing applied (recorded example without a key)

Source: https://keryn.dev/docs/reference/cli/ai/

> **Caution: Next release: keryn ai**
> On main; not in Keryn 0.5.2, the latest release.

Model-proposed triage, summary, threat model, exception drafts, ship-or-hold advice; nothing applied (recorded example without a key).

```text
keryn ai <task> --from <result>
```

## Options

```text
Usage: keryn ai <triage|summary|threat-model|exceptions|release> --from <result.json> [options]
  The model proposes, a person decides. Answers cite only findings the model was shown; nothing is changed unless approved.
  --model <id>          default auto: claude-haiku-5-5 for triage, claude-opus-5-5 for the rest (required with --provider)
  --provider <kind>     anthropic | openai | azure | bedrock | google | cloudflare | vercel | openrouter | ollama |
                        compatible (alias openai-compatible); default: Anthropic with the key below
  --base-url <url>      ollama (default http://localhost:11434/v1) and compatible endpoints; https, or http for localhost
  --key-env <NAME>      the environment variable holding the key (never printed); presets: OPENAI_API_KEY, GEMINI_API_KEY,
                        AI_GATEWAY_API_KEY, OPENROUTER_API_KEY; ollama and compatible may run without a key
  --resource/--region/--account/--gateway   azure resource, bedrock region, cloudflare account and gateway
  --recorded            show the recorded example instead of calling a model (the default when no key is found)
  --with-code           send redacted code excerpts (triage); only for --visibility public with cloud.sharing not off (#188).
                        This holds for every provider, including your own key and a local model: a private repository is
                        triaged from rule, message, file and line only (owner decision pending, #394).
  --visibility <v>      public | private (default unknown: treated as private, no code leaves)
  --approve <ids|all>   exceptions: the proposals a person approves (finding ids or their first characters)
  --write               exceptions: record the approved drafts in .keryn/decisions.yml as git user.email; refuses in CI
  --owner <name>        exceptions: owner of the drafts (default the approving person)
  --limit <n>           triage: how many findings to send (default 40)
  --json <file|->       the run as JSON
  Key: ANTHROPIC_API_KEY, else ~/.config/keryn/*.env (never printed). Usage is recorded in shadow (Keryn Credits, not billed) in
  ~/.local/state/keryn/agentic-usage.jsonl. release prints the canonical release decision ('keryn decide') first; the model never
  changes it or the exit code (always 0).
```

## Examples

```sh
# The release decision, then the model's advice beside it.
keryn ai release --from result.json

# Record one approved exception draft in .keryn/decisions.yml.
keryn ai exceptions --from result.json --approve 3f2a9c --write
```

## Exit codes

| Code | Meaning |
|---|---|
| 0 | proposals shown (never a gate) |
| 2 | bad usage, unreadable result, or --with-code not allowed by the sharing setting |
