# che.sh — full reference

> Anonymous decision trees you can curl. Nothing you send to your own trees is kept (runs on che.sh's demo checks are logged for the public benchmarks at https://che.sh/models). Decisions run on rvbbit (https://rvbbit.ai) in Postgres/SQL, using Jev decision models via OpenRouter. This file documents the live public HTTP API. For a short briefing, see https://che.sh/llms.txt.

che.sh stores trees and per-URL counts. It does not store or log inputs, outputs, or images. Demo trees may cache an answer keyed by a fingerprint (a hash) of the request so repeats are free; the cache never holds what you sent.

Agents and terminals should prefer `curl`. Browsers and link-unfurling bots get the HTML canvas (a black, nearly blank stage with wireframe trees). `curl`, `wget`, `httpie` and similar user-agents get plain text. Send `Accept: application/json` (and not `text/html`) for JSON. HEAD is answered like GET, without a body.

Curl always uses the latest Jev model (currently `typesafe/jev-1.14`). A quiet compare toggle in the web UI can run several decision models on the same input; that mode is not part of the curl interface.

Base URL: `https://che.sh`  (the host `che.sh` also works in curl without the scheme.)

________________________________________________________________

## Tree JSON

A tree `doc` is:

    {
      "v": 1,
      "root": "<id of the first question>",
      "nodes": { "<id>": { ... }, ... }
    }

Node ids are 1–24 characters: letters, digits, `_` or `-`.

There are two kinds of node.

**Question** (`kind: "ask"`):

    {
      "kind": "ask",
      "text": "Does the customer believe they were charged incorrectly?",
      "threshold": 0.6,
      "out": [
        { "label": "yes", "to": "y" },
        { "label": "no",  "to": "n" }
      ],
      "x": 115,
      "y": 175
    }

- `text` is the question, at most 400 characters.
- `out` has 2–8 ways out. Each has a `label` (1–40 characters, unique within the question, case-insensitive), a `to` pointing at another node, and an optional `hint` (at most 200 characters) that helps the model choose. For a yes/no question the hint is usually omitted.
- `threshold` is the yes/no cutoff, 0.05–0.95, default 0.5. A yes/no question takes the `yes` route when the model's yes-score is above the threshold.
- `x` and `y` are optional canvas positions.

**Answer** (`kind: "answer"`):

    {
      "kind": "answer",
      "text": "refund review",
      "x": 0,
      "y": 350
    }

`text` is at most 120 characters.

Rules: at most 40 nodes; at most 8 questions deep; every way out must lead somewhere; each node has at most one way in; nothing points back at the root; no blank questions or answers; the document as JSON is at most about 48 KB. A title, when you save a tree, is at most 80 characters. Slugs are 3–24 lowercase letters or digits.

A yes/no question becomes `rvbbit.branch(...)`. Any other set of labels becomes `rvbbit.choice_branch(...)`. Answers are `rvbbit.leaf(...)`.

### Extract steps and placeholders (public)

An `extract` node reads fields from the current text document with Clairic (`cloudflare/clairic`, through `rvbbit.clover_extract_fields`). No lab key or URL parameter is needed. The plain-English compose experiment is separate and stays owner-only.

In the editor, hover an answer and choose **⌗ find** (a two-way question also has this control). Type a comma/semicolon-separated list: `the business name, loan amount, credit score, ?collateral, missing documents (list)`. Names and likely types are normalized deterministically (no extra model call). The chips below the step show `{business_name}`, `{loan_amount}`, etc. `?` means optional. Override types with `: text`, `: number`, `: date`, `: list`. For explicit names, use `name = plain English description: type`. This simple helper does not infer arbitrary schemas with Jev.

API shape (a tiny smoke test, not a loan policy or SBA eligibility advice):

```json
{"v":1,"root":"x","nodes":{
  "x":{"kind":"extract","text":"loan basics","fields":[
    {"name":"business_name","type":"text","instructions":"the business name"},
    {"name":"loan_amount","type":"number","instructions":"requested loan amount in dollars"},
    {"name":"collateral","type":"text","instructions":"collateral offered","optional":true}
  ],"out":[{"label":"found","to":"q"},{"label":"missing","to":"m"}]},
  "q":{"kind":"ask","text":"Is the requested {loan_amount} dollar loan above 350000 dollars?","threshold":0.5,
       "out":[{"label":"yes","to":"a"},{"label":"no","to":"b"}]},
  "a":{"kind":"answer","text":"large amount: {business_name}"},
  "b":{"kind":"answer","text":"small amount: {business_name}"},
  "m":{"kind":"answer","text":"ask for {missing}"}
}}
```

Use `POST /api/trees` to claim a URL with this doc, or `POST /api/try` with `{doc, input}` to try without saving. Then:

    curl che.sh/<tree> -H 'Accept: application/json' --data-binary @application.txt
    curl che.sh/<tree> -H 'Content-Type: text/html' --data-binary @application.html

Only plain text and pasted HTML are read for extract steps, not image/PDF/Word/OCR or remote URLs. HTML is stripped deterministically (tags/scripts/styles/comments removed, common entities decoded). Raw input INCLUDING markup stays within 4000 characters. Malformed HTML and uncommon/numeric entities may not normalize perfectly. No fetching or JS execution.

**Fields:** each needs `name` (unique per node, lowercase a-z then a-z/0-9/_, 1–24 characters, not `found` or `missing`), `type` (text/number/date/list; default text), and `instructions` (plain English, up to 200 characters; defaults to the name). Lists contain text. Dates do not assume a reference date/year. Bool is not supported by rvbbit's installed extraction adapter. Optional fields use `optional: true`. In the editor list, `name = description: type` sets a name explicitly. At most 12 fields per node and 4 extract nodes per tree; they count toward 40 total nodes and 8 levels.

**Routes:** exactly two, named `found` and `missing`. Found means every REQUIRED field has a nonempty, correctly typed, non-null value with confidence ≥0.5 and p_null <0.5. Missing, low-confidence and guessed-only fields are not used (the provider's `guess` property is never read). Optional fields don't block `found`. Some legitimate fields may therefore route missing. Extraction/model errors are errors, not missing data.

**Variables:** all accepted fields are carried forward for this run; a later extract can replace a same-named field. Missing fields become JSON null, not invented data. `{missing}` is the required names not found in the last extract. Later question/answer text and choice hints support `{field_name}`. Unknown placeholders are rejected at compile time if there is no earlier extract defining them. Substitution is one pass, never eval/SQL/template execution; strings are literal data, lists become comma-separated text and null becomes `(not found)`. Long field values and assembled text are bounded. Extract values remain uncertain model judgments, not facts. Keep important policy rules as questions and review the trace.

**Response:** the ordinary decision response adds `variables` (the per-run map), `extractions` (each step's node, model, route, accepted values, missing required names, time and cost), and `extract_cost_usd`. `cost_usd` stays downstream decision cost; add the two for a single run's total. The browser shows found/missing values in the trace and the step's explanation, only in that tab. In compare, shared extraction data is charged once and marked `shared` on the other model's trace; each decision model card keeps downstream decision timing/cost, and the compare total includes extraction once. A model that takes a different branch can reach a different extract step; that step is read as needed.

**Repeat inputs:** sending the exact same text again reuses the earlier extract read and decision steps from an in-memory cache (6 hours, per process, lost on restart): the run costs $0, does not count toward the per-IP extract limit, and reports `cached: true` with the original uncached numbers (`orig_cost_usd`, `orig_ms` on the run; `cached`, `orig_cost_usd`, `orig_ms` on each extraction). Over the per-IP extract limit, only cached reads are served; anything else returns `rate_extract`. The browser result line shows the total with an `incl. extract $… · …ms (clairic)` line; in compare the shared read is one line and card costs are decisions only. curl text output and share pages show the same line.

**Limits and privacy:** default 8 real extract-step calls/minute and 80/day per IP, 3 concurrent extract runs; also 1500 extract calls/day, $0.25/day and $3/month for the extract bucket, all inside the site's existing daily/monthly caps. These are switches/settings, not a paid account. Documents and found values are never stored/logged by che.sh. Only numeric spend/counts and hashes are kept, receipts are scrubbed in the transaction, and extract-tree run outputs never enter the persistent demo answer cache; repeat inputs use a memory-only cache keyed by HMAC with a per-process secret (values trimmed to what replay needs). The browser may hold results in memory until the tab closes. Shares strip all found values/filled questions and labels unless the user explicitly includes the text input; even then the variable/field maps are not persisted. Photos are never stored. In the editor, documents are read in the tab and only their text is sent; scanned pages and photos of documents go to `POST /api/ocr`, are read in memory and discarded. Field definitions and placeholder templates (not values) are the saved tree. Don't paste real SSNs or other sensitive data into shared tree definitions.

**Models:** `chesh.settings.extract_model` selects an entry in the server-only `extract_models` whitelist. Today it maps `cloudflare/clairic` to the installed `clover_extract_fields` operator. New models need a vetted adapter/whitelist entry, never a client-chosen URL/operator. No rvbbit core/operator/global-cache settings are changed.

### Example: the public refund-triage demo (`che.sh/demo`)

    {
      "v": 1,
      "root": "r",
      "nodes": {
        "r": {
          "kind": "ask",
          "text": "What does the customer need help with?",
          "threshold": 0.5,
          "out": [
            { "label": "billing",    "hint": "Invoices, charges, payments or refunds", "to": "b" },
            { "label": "scheduling", "hint": "Appointments, dates or availability",    "to": "s" },
            { "label": "other",      "hint": "Anything else, or unclear",              "to": "o" }
          ]
        },
        "b": {
          "kind": "ask",
          "text": "Does the customer believe they were charged incorrectly?",
          "threshold": 0.6,
          "out": [
            { "label": "yes", "to": "y" },
            { "label": "no",  "to": "n" }
          ]
        },
        "y": { "kind": "answer", "text": "refund review" },
        "n": { "kind": "answer", "text": "explain the invoice" },
        "s": { "kind": "answer", "text": "send to scheduling" },
        "o": { "kind": "answer", "text": "a human should look" }
      }
    }

(The live demo also stores `x`/`y` for the canvas; they are optional.)

________________________________________________________________

## Public endpoints

### GET /

In a browser: the editor canvas.
From curl: a short briefing, including curl examples.

    curl che.sh

    # (plain text, 200, content-type: text/plain; charset=utf-8)
    # begins with a little grin, then:
    #   che.sh: decision trees you can curl.
    #   curl che.sh/<tree> -d "my card was charged twice"     ...

### POST /

Returns the same briefing plus a hint to POST to a tree, status 400.

    curl -X POST che.sh

### GET /{slug}

Describe a tree. Curl prints a text outline; `Accept: application/json` (or `GET /api/trees/{slug}`) returns the stored doc.

    curl che.sh/demo

    che.sh/demo: refund triage (demo)
      ? What does the customer need help with?
        billing → ? Does the customer believe they were charged incorrectly?   (yes if > 0.60)
            yes → "refund review"
            no → "explain the invoice"
        scheduling → "send to scheduling"
        other → "a human should look"

      curl che.sh/demo -d "your text"
      curl che.sh/demo -F image=@photo.jpg

    curl -s -H 'Accept: application/json' che.sh/demo
    # { "ok": true, "slug": "demo", "title": "refund triage (demo)",
    #   "doc": { "v": 1, "root": "r", "nodes": { ... } },
    #   "n_nodes": 6, "depth": 2, "revision": 1,
    #   "created_at": "...", "updated_at": "..." }

`/hotdog` is an alias for `/5gs8g`. Browsers are redirected (302) to the real slug; curl is served the tree directly (curl does not follow redirects by default). Usage is counted under the real slug.

Unknown slugs: 404, `no tree here. the Cat has vanished, or never was.`

### POST /{slug}

Run the tree. This is the main interface.

    curl che.sh/demo -d "you charged me twice, fix it"

    → refund review   0.98
      What does the customer need help with?                    billing 1.00
      Does the customer believe they were charged incorrectly?  yes 0.98

    curl -s -H 'Accept: application/json' che.sh/demo -d "you charged me twice, fix it"

    {
      "ok": true,
      "status": "complete",
      "label": "refund review",
      "confidence": 0.98,
      "path": [
        {
          "node": "root",
          "question": "What does the customer need help with?",
          "route": "billing",
          "score": 1,
          "p": 1.0
        },
        {
          "node": "root/billing",
          "question": "Does the customer believe they were charged incorrectly?",
          "route": "yes",
          "score": 0.98,
          "p": 0.98,
          "threshold": 0.6
        }
      ],
      "model": "typesafe/jev-1.14",
      "steps": 2,
      "ms": 0,
      "cost_usd": 0,
      "cached": true
    }

`p` is the probability of the route that was taken (for a yes/no step, `p` is the yes-score when the route is yes, and `1 - score` when the route is no). `confidence` is the product of those `p` values, rounded to three decimals. `cached: true` means a demo tree remembered this answer; `ms` and `cost_usd` may be 0. A fresh call looks the same, with real `ms` and a tiny `cost_usd` (often a fraction of a thousandth of a dollar) and `cached: false`.

An uncached text example (`curl che.sh/hha7a` with a buying lead) returned `"label": "book a call today"`, `"confidence": 0.757`, `"steps": 3`, `"ms": 378`, `"cost_usd": 0.000062832`, `"model": "typesafe/jev-1.14"`, `"cached": false`.

**Input formats** (all of these work):

    curl che.sh/demo -d "plain text"
    curl che.sh/demo --data-urlencode "text=plain text"
    curl che.sh/demo -H 'Content-Type: application/json' -d '{"text":"plain text"}'
    # also accepted in JSON or forms: "input" or "q"

    curl che.sh/5gs8g -F image=@lunch.jpg
    curl che.sh/5gs8g -F image=@lunch.jpg -F text="a caption"
    curl che.sh/5gs8g --data-binary @lunch.jpg -H 'Content-Type: image/jpeg'

Photo example, using the preloaded hot-dog tray at https://che.sh/static/demo/hotdog.jpg:

    curl che.sh/5gs8g -F image=@hotdog.jpg

    → multiple hot dogs   0.93
      Is this a hot dog?            yes 0.95
      is it more than one hot dog?  yes 0.98
      (looked at a 512×412 image · remembered, $0; not kept)

JSON for the same call adds `"image": {"w": 512, "h": 412, "bytes": 21081}` and `"cached": true`. Images are shrunk in memory, looked at, and discarded.

Empty body: 400, `say something:  curl che.sh/<tree> -d "your text"`.
More than 4000 characters of text: 413.
An image that is not jpeg/png/webp/gif: 415, `the Cat can't see that.`
An image over 2 MB (or 24 megapixels): 413.

Whole pages: `-H 'Content-Type: text/html' --data-binary @page.html` (up to 2.4 MB) converts the page to markdown first (see `POST /api/page`), then runs the tree on at most 16,000 characters under the per-IP file bucket. JSON responses add `page: {title, chars, sections, cut}`.

    curl -s che.sh/product -H 'Content-Type: text/html' -H 'Accept: application/json' --data-binary @kettle.html

    {"ok": true, "label": "well reviewed: 4.7★ from 2318 reviews · $39.00", "confidence": 0.916, ..., "page": {"title": "Burrow Trail Kettle 1.2 L, titanium | Hatter & Hare Outfitters", "chars": 1411, "sections": {"page": 77, "metadata": 193, "structured": 403, "prices": 76, "content": 654}, "cut": false}}

**Chaining (follow).** If the answer a tree reaches names another tree, che.sh runs that tree on the same input and returns its answer: `→ 8fzct`, `-> che.sh/sba`, `=> https://che.sh/8fzct`, or a bare `che.sh/8fzct` in the answer text (aliases work; the tree must exist, otherwise the answer is just text). There is no special node: a "router" is an ordinary tree whose answers name trees, e.g. [che.sh/router](https://che.sh/router). At most 3 more trees are followed and none twice (`stopped: "loop"` / `"max_hops"`); each tree is billed and rate-limited as a normal call. Turn it off with `?follow=0`, `X-Che-Follow: 0`, or `"follow": false` in `/api/run` / `/api/try` JSON. JSON adds `follow: {hops: [{tree, label, confidence, path, cost_usd, ms, cached}], trees, stopped, total_cost_usd, total_ms, final}`, and the top-level `label`, `path` and `tree` are the last tree's. Plain text adds a `↳` line per tree and a `chain:` total:

    $ curl che.sh/router -d "you charged me twice for the same order, please refund one"
    → refund review   0.97
      ↳ 82vg9: → demo  1.00
      chain: 82vg9 → demo · $0.0000589 · 606ms
      What does the customer need help with?                    billing 1.00
      Does the customer believe they were charged incorrectly?  yes 0.97

In the editor the canvas keeps the tree you are drawing; the hops show under the verdict, a quiet `follow` toggle appears when an answer names a tree, and typing `→ ` in an answer offers the trees in your local list. Compare (several models) does not follow.

### GET /api/status

Live limits and whether the cat is awake. No auth.

    curl -s che.sh/api/status

    {
      "awake": true,
      "images": true,
      "max_input_chars": 4000,
      "max_nodes": 40,
      "max_depth": 8,
      "max_branches": 8,
      "max_question_chars": 400,
      "max_answer_chars": 120,
      "demo_slugs": ["5gs8g", "gxgzg", "demo", "5b9n7", "hha7a"]
    }

`awake: false` means the cat is napping (treat budget spent, or a pause). `images: false` means photos are off; text still works. `demo_slugs` is the current set of trees with the looser demo limits and the lasting answer cache.

### POST /api/trees

Claim a URL. Body: `{ "doc": { ... }, "title": "optional, 80 chars" }`. Returns 201:

    { "ok": true, "slug": "abcde", "edit_key": "<edit_key>", "revision": 1,
      "url": "https://che.sh/abcde" }

Keep `edit_key`. It is shown once. Send it later as the `X-Edit-Key` header. You can also just open https://che.sh, draw a tree, and click "claim a url".

### GET /api/trees/{slug}

Same JSON as `GET /{slug}` with `Accept: application/json`.

### PUT /api/trees/{slug}

Update a tree you claimed. Header `X-Edit-Key: <edit_key>`. Body: `{ "doc": { ... }, "title": "..." }`.

    { "ok": true, "slug": "abcde", "revision": 2 }

Wrong or missing key: 403, `that's not this tree's key.`
Invalid doc: 422, `{ "ok": false, "error": "invalid_tree", "message": "…" }`
(the message is a short, human line such as `a question needs 2 to 8 ways out`).

To fork a public tree (including a demo), GET its `doc` and POST `/api/trees` with a copy. You get a new slug and your own key. In the browser this is the "fork" button.

### GET /api/usage/{slug}

Call counts for a tree you own. Header `X-Edit-Key: <edit_key>`. Returns counts, ok/failed, steps, and `cost_usd` for recent days — never inputs or outputs. Wrong key: 403.

### POST /api/try

Preview an unsaved (or just-edited) doc without claiming a URL. Used by the canvas. Body:

    { "doc": { ... }, "input": "some text" }
    { "doc": { ... }, "input": "optional caption", "image": "data:image/jpeg;base64,..." }
    { "slug": "demo", "doc": { ... }, "input": "..." }

JSON in, JSON out, same decision shape as `POST /{slug}`. If `slug` is a current demo tree and the doc matches, the demo cache may answer. Images in `/api/try` are `data:image/(jpeg|jpg|png|webp|gif);base64,...` (the editor shrinks them first).

### Known answers: POST /api/known/{slug}

A tree's owner can mark the right answer for one exact input on the saved tree. In the browser: hover the result line (or a compare card) and choose `mark right`; `unmark` removes it. Directly:

    curl -s che.sh/api/known/<slug> -H 'x-edit-key: <your key>' -H 'Content-Type: application/json' \
      -d '{"input": "you charged me twice, fix it", "leaf": "<answer node id>"}'

    {"ok": true, "marked": true, "leaf": "y", "expected": "refund review"}

Body: `input` (text, same size cap as a run), optional `image` (a data URL, same caps as `/api/try`), `leaf` (an answer node id; `null` unmarks), optional `doc` (if sent and its routing differs from the saved tree: 409 `save_first`), optional `sample` (a short label, 40 chars). Errors: 403 `wrong_key`, 400 `not_an_answer`, 409 `save_first`, 409 `known_full` (200 marks per tree; marks from older versions of the tree are dropped first), 429 `rate` (30/minute per IP).

What is stored: the tree slug, a hash of the routing (reachable questions, thresholds, ways, answer texts and extract fields; layout is ignored), a keyed HMAC fingerprint of the input (normalized text; for a photo, a 64-bit perceptual hash of the prepared image plus the caption), the answer node, an optional sample label and the time. Never the text, the photo or a run result. Editing the tree's routing changes the hash, so old marks stop matching. Matching is exact: any change to the text, a crop or a different photo is a different input. A photo re-encoded or resized still matches.

When a run matches a mark, the JSON response includes `"known_answer": {"leaf": "y", "expected": "refund review", "correct": true}` (and `sample` when set), and curl text output adds `✓ matches the known answer` or `✗ known answer: …`. Compare runs carry `correct` per run, `known_answer` at the top, and `best` is chosen among the correct runs; with none correct there is no best.

### GET /models  and  GET /api/scoreboard

Every demo sample has a known answer, marked by che.sh. An owner-run sweep (manual, not scheduled) sends each sample through the decision models in compare; `/models` shows the latest sweep: per-model accuracy (overall, text, images), average decision cost and time, and per-sample results. `curl che.sh/models` prints a plain table; `GET /api/scoreboard` returns JSON (`sweep`, `ran_at`, `runs`, `spent_usd`, `models[]`, `samples[]`). Only model ids, sample names, answer ids, booleans, times and costs are stored for a sweep.

### POST /api/ocr

Read one page image (a scanned PDF page rendered by the browser, or a photo of a document). Used by the editor's file reader; you can call it directly. Body: raw `image/jpeg`, `image/png` or `image/webp` bytes, at most 2.5 MB and 20 megapixels.

    curl -s che.sh/api/ocr -H 'Content-Type: image/jpeg' --data-binary @page.jpg

    {"ok": true, "text": "FIRSTKEYSTONE BANK\nBusiness checking statement ...", "conf": 0.97, "lines": 21, "low": 0, "ms": 1800}

`conf` is the mean line confidence (0-1) and `low` counts lines read below 0.80; treat low-confidence text as a draft. The engine is RapidOCR (PP-OCRv4 detection + PP-OCRv3 English recognition, ONNX on CPU) in a separate sandboxed worker on the che.sh server. **Privacy:** the image is held in memory only, read, and discarded; it is never written to disk, logged, cached or shared, and the text goes back only in this response. Only a per-day page count (no content) is kept for the site cap. **Limits:** one page at a time server-wide (a short queue, then `ocr_busy`), 20 s per page, 12 pages a minute and 60 a day per IP, a site-wide daily page cap; the editor reads at most 5 OCR pages per packet. OCR costs no model spend; the extract step that reads the text is billed as usual.

### POST /api/page

Convert a web page's HTML to the compact markdown a tree reads (the same converter as a `text/html` POST to a tree, the extension's "use page", and saved `.html` files dropped in the editor). Body: JSON `{html, url?, title?}`; `html` up to 2.4 MB (request up to 2.9 MB). No model call and no cost.

    curl -s che.sh/api/page -H 'Content-Type: application/json' -d "$(jq -n --rawfile h page.html '{html:$h, url:"https://shop.example/item"}')"

    {"ok": true, "markdown": "# Burrow Trail Kettle 1.2 L, titanium | Hatter & Hare Outfitters\nurl: https://shop.example/item\nlanguage: en\n\n## Page metadata\n- description: A 1.2 litre titanium camp kettle ...\n- og:type: product\n\n## Structured data\n- @type: Product\n- name: Burrow Trail Kettle 1.2 L, titanium\n- brand.name: Hatter & Hare\n- aggregateRating.ratingValue: 4.7\n- aggregateRating.reviewCount: 2318\n- offers.price: 39.00\n- offers.priceCurrency: USD\n...\n\n## Prices seen on the page\n- $39.00 · $39.00 $49.00\n...\n\n## Page content\n# Burrow Trail Kettle 1.2 L, titanium\n\nby Hatter & Hare\n\n★★★★☆ 2,318 ratings\n...\n## Specifications\n\n- Capacity: 1.2 L\n- Weight: 182 g\n...", "page": {"chars": 1442, "sections": {"page": 108, "metadata": 193, "structured": 403, "prices": 76, "content": 654}, "blocks": 20, "blocks_total": 20, "cut": false, "title": "Burrow Trail Kettle 1.2 L, titanium | Hatter & Hare Outfitters"}}

Sections, in order: a header (title, URL, language), **Page metadata** (description, Open Graph / Twitter / product meta), **Structured data** (JSON-LD flattened, plus microdata; at most 45% of the budget), **Prices seen on the page** (currency amounts with a little context), **Page content** (headings, paragraphs, lists, tables; two-column tables become `- key: value`, wider ones markdown tables; aria-labels with numbers such as star ratings are kept in `[...]`). Dropped: scripts (except JSON-LD), styles, SVG, iframes, forms, navigation, headers/footers, cookie and promo banners, and duplicate lines. If the result is over 16,000 characters, the lowest-value blocks are trimmed first (`cut: true`), favouring the main region. Grid layouts (e.g. pricing feature matrices built from divs) flatten into lists, which can lose which value belongs to which column. **Privacy:** the HTML is converted in memory and discarded; nothing is written, logged or fetched (che.sh never loads the URL). **Limits:** 12 a minute and 120 a day per IP (shared with file runs).

### POST /api/run/{slug}

JSON run of a saved tree, used by the browser extension: `{input, files?, image?}`. `input` is text; with `files: true` it may be up to 16,000 characters (documents or a converted page, under the per-IP file bucket of 12 a minute / 120 a day), otherwise 4,000. `image` is a `data:image/...;base64,` URL (2 MB decoded) with `input` as an optional caption. Responds like `POST /{slug}` with `Accept: application/json`; same limits and accounting.

### POST /api/suggest  and  GET /api/cards

Which of my trees fits this? Send content and up to 10 tree ids; one Jev call scores each tree independently (0-1) against its public card. che.sh builds the card itself from the stored tree (title, one-line description, first question, extract field names, answers), so the client sends only ids. Nothing is routed or run: you pick, e.g. the extension shows "Run Product page check (56%)" buttons. Only the first 3,000 characters are read.

    curl -s che.sh/api/suggest -H 'Content-Type: application/json' -d '{"input": "you charged me twice, fix it", "trees": ["demo", "hha7a", "5b9n7", "8fzct"]}'

    {"ok": true, "trees": [{"id": "demo", "p": 0.98}, {"id": "hha7a", "p": 0.06}, {"id": "8fzct", "p": 0.01}, {"id": "5b9n7", "p": 0.01}], "cost_usd": 0.000057, "model": "typesafe/jev-1.14-20261014", "cached": false, "ms": 190}

`GET /api/cards?ids=demo,product` returns those cards (`id, title, description, revision, asks, fields, answers`). Scores are independent, so several trees can score high; treat anything under about 0.2 as no fit. Photos are not scored (send them to a photo tree). **Privacy:** the input is read once and discarded; only a daily count and cost are kept. **Limits:** 20 a minute and 300 a day per IP, a site-wide daily cap (`suggest_daily_cap`), and the usual nap (`napping`).

### GET /c/{sid}  and  GET /api/share/{sid}

A shared compare. Share ids are 8 lowercase letters or digits. Viewing one never calls a model. Share pages are not indexed.

    curl che.sh/c/e5ba6983

    che.sh/c/e5ba6983: 5 decision models vs one hot dog
      all agree  → multiple hot dogs
      input not shared
      jev-1.13                → multiple hot dogs  0.96  1448ms  $0.0000789
      jev-1.14                → multiple hot dogs  0.93  288ms  $0.0000787
      microsoft-decision-1.1  → multiple hot dogs  0.96  1200ms  $0.0000306  * best
      heygen-decision-1       → multiple hot dogs  0.99  2285ms  $0.00018
      groundhog-1             → multiple hot dogs  0.99  cached
      try it:  curl che.sh/5gs8g -d "your text"

`* best` is the Pareto pick on time vs cost among models that agree with the majority (or, if the input has a known answer, among the models that got it right). `GET /api/share/{sid}` (or `Accept: application/json` on `/c/{sid}`) returns the same payload as JSON, including each run's `path`. If the sharer opted in, a text `input` may be present. Photos are never stored on a share. Unknown id: 404, `no compare here.`

Compare itself lives in the browser UI (the quiet "compare" toggle next to the input). Curl on a tree always hits a single Jev call, not a compare.

### GET /og/{slug}.png  and  GET /og/c/{sid}.png

Open Graph preview images (1200×630 PNG) for a tree or a shared compare.

### GET /llms.txt, /llms-full.txt, /docs, /openapi.json

This documentation. `/docs` is the same body as `/llms-full.txt`. `/openapi.json` describes the public endpoints. Content-Type is `text/markdown; charset=utf-8` for the markdown files, `application/json` for the OpenAPI document. Cached for about an hour.

### GET /healthz

    curl che.sh/healthz
    # ok

### GET /robots.txt  and  GET /sitemap.xml

What they sound like. The sitemap lists the homepage, /models, /extension, /learn and each note, the learn Atom feed, these docs, and the public demo checks (friendly URLs such as /scam and /sba when they exist). Each URL has a lastmod date. Owner pages (/runs, /lab) and /api/ are omitted. The learn feed is GET /learn/feed.xml (also /feed.xml).

________________________________________________________________

## Errors

Plain text by default; JSON `{ "ok": false, "error": "<code>", "message": "…" }` when you asked for JSON.

    400 empty          say something:  curl che.sh/<tree> -d "your text"
    400 (POST /)       the briefing, plus a hint to POST to a tree
    403 wrong_key      that's not this tree's key.
    404 no_such_tree   no tree here. the Cat has vanished, or never was.
    404 no_such_share  no compare here. the Cat has vanished, or never was.
    413 too_long       that's more than 4000 characters. the Cat stopped listening.
    413 image_too_big  that image is too big for the Cat (2 MB, 24 megapixels max).
    415 bad_image      the Cat can't see that. send a jpeg, png, webp or gif.
    422 invalid_tree   (create/update) a short reason, e.g. at most 40 nodes per tree
    429 rate           slow down. even the Cat can only grin so fast. try again in a minute.
    429 rate_image     slow down: the Cat looks at N pictures a minute, M a day.
    429 slug_daily_cap this tree has answered enough for today. tomorrow, perhaps.
    429 image_daily_cap / image_slug_cap
                       the Cat has looked at enough pictures today. words still work.
    415 extract_text_only  extract steps read text or pasted html, not pictures.
    429 rate_extract / extract_daily_cap  document-reading limits are reached.
    502 extract_failed extraction service did not answer.
    413 ocr_too_big    (POST /api/ocr) that scan is too big for the Cat to read (2.5 MB, 20 megapixels max per page).
    429 rate_ocr / ocr_cap  scanned-page limits (per IP a minute / a day; site-wide a day) are reached.
    503 ocr_busy / ocr_timeout / ocr_off  the reader is busy, a page took over 20 s, or OCR is off.
    503 extract_busy / extract_off / extract_model  try again later.
    429 share_rate     slow down: 30 shared compares a day from here.
    502 unavailable    the Cat shrugged (the decision service didn't answer). try again.
    503 napping        the cat is napping. back soon.
    503 napping        the cat is napping: today's treats are gone. back tomorrow.
    503 napping        the cat is napping: this month's treat budget is spent. back on the 1st.
    503 images_off     the Cat has closed its eyes: images are off right now. words still work.
    503 busy           too many new trees today. come back tomorrow.
    503 share_full     too many shared compares just now. try again later.
    500                the Cat fumbled that one.

Be gentle. Ordinary trees will look at about 10 pictures a minute and 100 a day; demo trees allow about 40 a minute and 200 a day. Text has its own per-minute and per-day politeness limits (you'll get `rate` if you hit them). Demo trees are exempt from per-tree daily caps. Cached demo answers are cheap and may still work while the cat is napping.

________________________________________________________________

## Demo trees

Current slugs are also listed by `GET /api/status`.

- `https://che.sh/demo` — refund triage. `curl che.sh/demo -d "you charged me twice, fix it"`
- `https://che.sh/5gs8g` (alias `/hotdog`) — is it a hot dog? one lonely dog, or a whole tray (photo). `curl che.sh/5gs8g -F image=@lunch.jpg`
- `https://che.sh/hha7a` — inbound lead router: who gets a call today, who gets a kind no
- `https://che.sh/5b9n7` — the White Rabbit's calendar: should this meeting have been an email?
- `https://che.sh/gxgzg` — expense receipt check: snap a receipt, the cat reads the policy (photo)
- `https://che.sh/8fzct` (alias `/sba`) — SBA loan intake: a lender's first-pass triage of an application email. An illustrative screening demo, not lending advice. Try `curl che.sh/sba -H 'Accept: application/json' --data-binary @application.txt`

### The router demo (`che.sh/82vg9`, alias `/router`)

One multi-way question ("What is this input?") with eight ways out: support message → `demo`, sales lead → `hha7a`, meeting invite → `5b9n7`, loan request → `8fzct`, product page → `p4dw9`, food photo → `5gs8g`, receipt → `gxgzg`, and something else (a plain answer). Every answer except the last names a tree, so a call returns that tree's answer with the hop in `follow`.

### The product page demo (`che.sh/p4dw9`, alias `/product`)

Built for whole pages: send a shop's product page with the extension, or curl a saved page as `text/html`. One extract step finds `product_name`, `price` (optional), `rating`, `review_count` and `brand` (optional); missing ones take the missing branch. Then: at least 4.5 stars from 1,000+ reviews → "well reviewed"; at least 4.0 from 100+ → "decent"; otherwise "risky". The site's samples are two fictional saved shop pages.

### The SBA loan intake demo (`che.sh/8fzct`, alias `/sba`)

34 nodes, at most 7 decisions on any path. It starts with one extract step and then routes with yes/no and multi-way questions that use `{placeholders}`. **It is an illustrative screening demo, not lending advice.** Real eligibility and credit decisions belong to the lender, the CDC or SBA. The rules are simplified from public sources: 13 CFR 120.110 (ineligible businesses), 120.120 (uses of proceeds), 120.707 (microloans), 120.931 (504 limits), SOP 50 10 8 / 8.1 (7(a) Small loans up to $350,000, SBA Express up to $500,000, 7(a) up to $5M, a 10% equity injection for startups) and SBA Procedural Notice 5000-876626 (from March 1, 2026, 100% U.S. citizen or U.S. national ownership).

1. **read the application** (extract, Clairic): business_name and loan_amount are required. Optional fields are industry, years_in_business, use_of_proceeds, annual_revenue, employees, credit_score, collateral, equity_injection and missing_documents (a list). If a required field is missing, the tree answers "incomplete intake: reply asking for {missing}".
2. **what kind of business** (operating / lending / passive real estate / restricted / nonprofit). Every option except operating ends in a decline with the matching 13 CFR 120.110 paragraph.
3. **ownership and character screen** (non-U.S.-citizen or non-resident owner, an owner incarcerated, on parole or under indictment, a prior loss on a federal loan) goes to a compliance hold.
4. **missing paperwork** goes to "request documents before review: {missing_documents}".
5. **which program**, checking the amount first: too big (over $5M) / microloan (up to $50K) / SBA Express (up to $500K) / standard 7(a) (up to $5M) / 504 (owner-occupied real estate or long-life machinery).
6. **risk flags** for each program. A start-up is a business that has been generating revenue for 1 year or less (SOP 50 10 8); in standard 7(a) a start-up also gets the 10% equity-injection check. For 504, a new business (2 years or less) contributes at least 15%. For microloans, under 2 years only sends the application to a technical-assistance track, which is illustrative intermediary practice, not an SBA rule. Credit under 680 or recent credit problems is flagged (the 680 cutoff is illustrative lender policy, not SBA's). Weak collateral is never a decline reason on its own. Each flag goes to a named underwriter queue.

The editor shows four sample emails: a clean 7(a), a microloan, an ineligible lender and an application with missing documents. A first run makes one real extraction call and up to six Jev judgments, which comes to about a tenth of a cent. Clicking the same sample again is answered from the in-memory repeat cache at $0, shown as cached with the original cost and time. In compare, the email is read once and each decision model judges the same fields, which makes the demo a usable benchmark for multi-step routing.

________________________________________________________________

## SQL equivalent

Trees with extract steps export as plain rvbbit SQL as well: each extract step becomes a CTE calling `rvbbit.clover_extract_fields(body, fields, '')`, found/missing becomes a `CASE` on value + confidence + p_null, and `{placeholders}` become `replace(...)` over the extracted value, so the per-row tree is built in SQL and fed to `rvbbit.decision_tree`. It is close to che.sh but not identical: the export reads every extract step for every row, and Jev sees the text only (che.sh also passes the found fields as evidence).

    WITH inputs(id, body) AS (VALUES (1, 'We want $250,000 for a second oven.')),
    x_x AS (
      SELECT i.id, rvbbit.clover_extract_fields(i.body,
        '{"loan_amount":{"type":"number","instructions":"requested loan amount in dollars"}}'::jsonb, '') AS f
      FROM inputs i
    )
    SELECT i.id, d ->> 'label' AS decision, d -> 'path' AS why
    FROM inputs i JOIN x_x USING (id),
         LATERAL (SELECT CASE WHEN (x_x.f #>> '{answers,loan_amount,value}') IS NOT NULL
                               AND (x_x.f #>> '{answers,loan_amount,confidence}')::float8 >= 0.5
                         THEN rvbbit.branch(
                                replace('Is {loan_amount} over 350000 dollars?', '{loan_amount}', x_x.f #>> '{answers,loan_amount,value}'),
                                rvbbit.leaf('large'), rvbbit.leaf('small'), 0.5)
                         ELSE rvbbit.leaf('ask for the loan amount') END AS t) tree,
         LATERAL rvbbit.decision_tree(i.body, tree.t, 16) AS d;

Decision-only trees export like this:


The canvas SQL button shows the same tree as plain rvbbit SQL, meant to be run in your own Postgres. A teaser for `che.sh/demo`:

    -- che.sh/demo, as plain rvbbit SQL.
    -- same functions che.sh calls; each question is one Jev judgment.
    WITH inputs(id, body) AS (
      -- one row per thing to judge: add rows, or swap in your own table
      -- (e.g. SELECT id, body FROM support_tickets)
      VALUES (1, 'you charged me twice, fix it')
    ),
    tree AS (
      SELECT rvbbit.choice_branch(
        'What does the customer need help with?',
        jsonb_build_object(
          'billing', 'Invoices, charges, payments or refunds',
          'scheduling', 'Appointments, dates or availability',
          'other', 'Anything else, or unclear'),
        jsonb_build_object(
          'billing', rvbbit.branch(
            'Does the customer believe they were charged incorrectly?',
            rvbbit.leaf('refund review'),
            rvbbit.leaf('explain the invoice'),
            0.60),
          'scheduling', rvbbit.leaf('send to scheduling'),
          'other', rvbbit.leaf('a human should look'))) AS t
    )
    SELECT i.id,
           d ->> 'label'  AS decision,
           d -> 'path'    AS why
    FROM inputs i, tree,
         LATERAL rvbbit.decision_tree(i.body, tree.t, 16) AS d;

For a photo, the `inputs` body is a JSON array that may include `rvbbit.image_part(...)`. Learn more at https://rvbbit.ai.

________________________________________________________________


## Learn

Short articles at https://che.sh/learn, written for people who want to classify text in SQL or chain extract, decide and route:

- https://che.sh/learn/decision-models-vs-chat
- https://che.sh/learn/classify-a-million-rows
- https://che.sh/learn/extract-then-decide

Figures in those notes come from https://che.sh/models.

## About

che.sh is a free Datarabbit thing by Ryan Robitaille ([@ryrobes](https://x.com/ryrobes)). Decisions run on [rvbbit](https://rvbbit.ai). Judgments are model guesses, not facts.
\n\n## Browser extension\n
Browser extension (Chrome, v0.3): open the side panel and, if you allow page reading, the page you are on is captured (scripts, media, form values and editable areas removed), converted to markdown by `POST /api/page` and scored against your saved checks by `POST /api/suggest`, only while the panel is open; nothing is stored. Click a suggested check to run it (`POST /api/run/<id>` with `follow: false`); the panel shows a plain answer with Sure / Fairly sure / Not sure and keeps a local results table you can export as CSV. Right-click Send to che.sh (selection, link, image, page) replaces the page as the content. The panel then reports which suggestion was clicked to `POST /api/suggest/feedback` (`{kind, trees: [{id, p}], picked, hinted}`; ids and scores only, no content, URL or domain; kept 90 days). Install: https://che.sh/extension. Privacy: https://che.sh/extension/privacy.

### The scam demo (`che.sh/kek4b`, alias `/scam`)

"Is this email or text a scam?" reads a pasted message in one extract step: claimed sender, full sender address/number,
sender domain, link domains, what the message asks for, payment method, urgency/threats and personal details requested.
One seven-way question sorts the kind (account alert, delivery/toll, prize/refund, urgent favor, bill/charge, code/receipt,
newsletter/promo), then one question per kind applies that kind's rule. Answers explain the reason: fake account alert,
delivery/toll fee bait, prize fee bait, boss/family gift-card request, fake renewal/call-to-cancel, mismatched links,
or a routine notice/newsletter. A missing claimed sender is "not enough to judge".

16 made-up canon messages cover all 15 answers (including a routine order, a no-link 2FA code and a newsletter).
All sample web addresses use reserved .example domains. This is illustrative screening, not security advice or a
verification of a sender: a display name/address and even a matching domain can be spoofed. "Looks fine" never proves
safety. Open the company's app or type its known address, and confirm money requests with a known contact number.
Don't paste real passwords, one-time codes or account/card numbers. This is a house demo: the same visible run-log
notice and privacy rules as the other demos apply. Its canon inputs count in /models; noncanon visitor text never scores.

    curl -s che.sh/scam -H 'Accept: application/json' -d "Lantern Mail: 482913 is your verification code. Do not share it. (from 52817)"

The router demo is left at its current routing version (eight ways out): extension detection uses the updated saved
flow list to suggest this flow, without invalidating that router's earlier scores.
