Use cases · Last updated

Model routing with Jev

The use-case map lists model routing as a first-class job: classify intent and domain, estimate difficulty and risk, escalate only what needs a more expensive model.

You implement that as a Choice (and maybe a difficulty Score) on the latest user message or the full state. Your code maps choice → provider id. Jev is the router, not the actor that generates the answer.

LangChain documents ModelRouterMiddleware in langchain_typesafe.experimental.middleware: you declare named ModelChoice entries with criteria strings, plus instructions such as “choose the least costly model that can complete the task.” The router reads the latest user message and selects a model for the run. Probabilities and confidence remain in agent state. Those APIs are LangChain’s. They still consume a TypeSafe key. If the package moves, believe current LangChain docs.

Gate low-confidence routes to the safer (usually costlier) model or to a human. That is cheaper than sending every prompt to the frontier chat model “just in case.”

See intent routing when the first cut is handler class, not model class. See agent loops when people want Jev to be the agent.

Worked sketch: PR review model class

A code-review bot should not default to the frontier chat model. The decision is which model class should write the comment, not which handler owns the ticket.

{
  "pr": {
    "title": "Tighten CSS tokens on billing receipt",
    "files": ["src/styles/receipt.css"],
    "has_screenshot": false,
    "diff_chars": 840
  }
}
Id Type Job
model_class Choice fast_text / reasoning / vision / other
difficulty Score nit → local change → cross-service risk (2–10 levels; we use 4)
cls = answers["model_class"]
if cls.confidence < FLOOR:          # illustration — fit on labels
    return call(REASONING_ID)       # fail toward the safer class
route = {
    "fast_text": FAST_ID,
    "reasoning": REASONING_ID,
    "vision": VISION_ID,
}[cls.choice]
return call(route)

fast_text for a CSS token tweak; reasoning when the diff touches auth or money paths; vision only when has_screenshot is true and the Choice lands on vision. Conjunctions stay in code. Jev never writes the review.

LangChain ModelRouterMiddleware is optional depth for the same Choice-over-class idea. Do not treat their class names as TypeSafe primitives.

When not to use

Pin jev-1.13.0 after floors settle. Vendor list price $0.042 / M input (claim — confirm on models). Official SDKs retry 429/529 only.

FAQ

Is ModelRouterMiddleware a TypeSafe API? No. It is LangChain’s. Jev still answers the Choice. See LangChain harness.

Choice vs Score for “how hard is this PR”? Choice picks a class (≤255 options). Score rates difficulty (2–10 levels). Confidence exists on both; Noul has none.

Should low confidence pick the cheapest model? Usually no. Fail toward the safer (often costlier) class or a human.

Can jev.pro issue the TypeSafe key the middleware needs? No. We do not sell keys. Confirm access on docs.typesafe.ai.

Hub: Use cases. Official: docs.typesafe.ai.

Disclaimer

This is an independent unofficial site and is not affiliated with TypeSafe AI; official documentation is available at https://docs.typesafe.ai. Never treat jev.pro as TypeSafe official documentation. We do not sell, issue, or proxy API keys.

Sources