Skip to main content
POST
Suggest a Rule From Corrections
Generates a single suggested rule derived from the caller’s recent corrections for a given mode. Two-tier:
  1. Deterministic first. A pure helper extracts the highest-DF content tokens across the cluster’s prompts and assembles a safe \b(token1|token2|…)\b pattern. Vendor-name-scrubbed.
  2. LLM fallback. If the deterministic helper returns nothing (no surviving tokens), Theo asks an internal classifier model for a single regex that matches the sample prompts. Output is re-scanned for vendor names and compiled before being trusted. A fallback that fails either check returns 404 so no unsafe rule ever escapes.
The endpoint does not auto-append the rule. Callers PATCH the suggestion onto an existing preference (or add it to a new one) via PATCH /api/v1/routing-preferences/{id}.

Authentication

Requires a Bearer token with the billing API key scope.

Body

string
required
The Theo mode whose correction cluster you want a rule for.

Request Examples

curl

Response

confidence is 0.88 when the deterministic helper produced the pattern, 0.78 when the LLM fallback did.

Errors

  • 400 routing_suggest_below_threshold — Cluster for the requested mode has fewer corrections than the cluster threshold.
  • 404 not_found — No cluster exists for expected_mode, or no safe rule could be derived from the available samples.