Model resolution matrix
Which model fires for which call class, resolved per provider family at session start.
Every call into the runtime resolves to a concrete model through a
(ProviderFamily × CallClass) matrix. The family is locked at
session start (it picks tokenizer, prompt-cache key, tool-call dialect,
and refusal pattern); the call class is declared per-call by the
seam that's invoking the LLM.
This page is the reference table for the routing cluster. The three concepts — CallClass, Seam, family-lock — that decide which model fires for which kind of call are framed in Family-lock → the routing cluster.
The matrix
anthropic | openai | google | deepseek | moonshot | mistral ‡ | qwen | thinkingmachines | xai | |
|---|---|---|---|---|---|---|---|---|---|
synthesize | claude-sonnet-4-6 | openai/gpt-5.6-luna-pro | google/gemini-3.8-flash | deepseek/deepseek-v4.1-flash | moonshotai/kimi-k2.5 | mistral-large-latest | qwen/qwen3.7-flash | thinkingmachines/inkling | x-ai/grok-4.6 |
reasoning | claude-sonnet-4-6 † | openai/gpt-5.6-luna | google/gemini-3.8-flash † | deepseek/deepseek-v4-flash | moonshotai/kimi-k2.5 † | mistral-large-latest † | qwen/qwen3.7-flash † | thinkingmachines/inkling-small | x-ai/grok-4.6 † |
converse | claude-haiku-4-5 | openai/gpt-5.6-luna | google/gemini-3.8-flash † | deepseek/deepseek-v4.1-flash † | moonshotai/kimi-k2.5 † | mistral-small-latest | qwen/qwen3.7-flash † | thinkingmachines/inkling-small | x-ai/grok-4.6 † |
utility | claude-haiku-4-5 | openai/gpt-5.6-luna | google/gemini-3.8-flash † | deepseek/deepseek-v4.1-flash † | moonshotai/kimi-k2.5 † | mistral-small-latest | qwen/qwen3.7-flash † | thinkingmachines/inkling-small | x-ai/grok-4.6 † |
† Resolves to the same model id as that family's synthesize rung —
either an explicit alias-up (anthropic and mistral reasoning: no distinct
mid-rung model exists) or a single-rung family where every call class
shares one model (google, moonshot, qwen, xai). deepseek keeps
deepseek-v4.1-flash on synthesize, converse and utility and puts
reasoning on a second rung, deepseek-v4-flash. openai (luna →
luna-pro) and thinkingmachines (inkling-small → inkling) carry a real
two-rung ladder.
‡ mistral is not currently exposed for routing. Its matrix
entries are placeholder model ids (mistral-small-latest /
mistral-large-latest) that don't resolve at any transport, so the
family is excluded from the list of exposed families and a session cannot lock
to it today. The row is shown for matrix completeness only.
The live matrix is the source of truth — it lives in @pleach/core
and is the only place edited when a model is added or rotated. A
future build of this page will regenerate the table directly from
the published matrix; until then, treat this rendering as a
snapshot suitable for orientation, not for procurement decisions.
Call classes
| Class | When the runtime picks it | Why it has its own row |
|---|---|---|
synthesize | The single final answer for a turn. | Highest-quality model per family; exactly one of these fires per turn. |
reasoning | An intermediate generator whose output feeds the next call. | Quality matters, but it's not user-visible prose — a smaller model is acceptable. |
converse | Short user-facing prose (clarifying questions, refusal hints, retry narration). | Latency-sensitive and conversational — typically the cheapest model that can hold the voice. |
utility | Internal classification or extraction (intent detection, refusal repair). | Pure machine-consumed; cheapest model the family ships. |
The classes are a downgrade ladder: synthesize → reasoning → converse → utility is the cost-quality direction.
Transports
Family choice fixes the tokenizer; transport choice fixes how the request gets to the provider. Both lock at session start.
| Family | Available transports |
|---|---|
anthropic | native · openrouter · byok-native · byok-openrouter |
openai | native · openrouter · byok-native · byok-openrouter |
google | openrouter · byok-openrouter (native pending) |
deepseek | openrouter · byok-openrouter (native pending) |
moonshot | openrouter · byok-openrouter |
mistral ‡ | not exposed for routing — placeholder model ids (see the matrix note above) |
xai | openrouter · byok-openrouter (native pending) |
Families without a native provider collapse native and byok-native
requests to their OpenRouter equivalents at resolve time, rather than
dispatching to a transport that doesn't exist. The resulting
transport is recorded on the audit row, so the collapse is visible
after the fact.
native reaches the provider directly. openrouter routes through
OpenRouter — useful for evaluation and for families without a native
transport. byok-* variants delegate credentials to the end user's
BYOK key rather than the deployment's. Transport is session-scoped, so
mid-session escalation across transports doesn't silently happen.
A session that starts on anthropic + byok-native and exhausts the
user's key surfaces the exhaustion through the ledger as a
providerCascade row with outcome.status: "exhausted", not a
silent flip to the deployment's own credentials.
Per-call-class overrides
SessionRuntimeConfig.perCallClassModelRouting replaces the matrix
rung for named call classes. It's a partial map from call class to
model id, read once at construction. Classes you leave out keep their
matrix rung.
const runtime = new SessionRuntime({
// ...
// anthropic session: serve converse calls from the synthesize rung
perCallClassModelRouting: { converse: "claude-sonnet-4-6" },
});@pleach/coding-agent/policy ships createPerCallClassRouting({ routes }),
which stamps the same field from a policy
(Multi-synthesize).
An absent, empty, or all-blank map leaves the runtime on the unrouted
path.
Which adapters honour it. The runtime passes the routed id to
adapter.resolveModel as the call's modelOverride. Core's
createProviderAdapter and the quickstart standard adapter (what
createPleachRuntime wires) resolve to it and serve it. An adapter
that ignores the override keeps its own model, and the decision is
recorded as not-honored rather than applied.
Cross-family routes are refused. The routed id's family is derived
and compared with the session's locked family. The route is refused
when the families differ (cross-family), when no family can be
derived from the id (family-unknown), or when the lock isn't
observable yet (lock-unobservable). A family that was only defaulted
counts as unobservable, not as a lock. A refused call resolves as if
unrouted. The refusal is disclosed by a [PerCallClassRouting] override-refused
probe and by the decision stamped on auditMetadata.perCallClassRouting
(requestedModelId, status, reason, and the requested and locked
families). Change families by re-locking the session, not by routing.
Pricing follows the model served. createPleachRoute (and so
createPleachAgent) and createPleachRuntime with a provider build
one model-config snapshot per runtime from OpenRouter's /models
catalog. Every resolveModel then stamps the rates of the model it
resolved, whether that's a matrix rung, a routed override, or a pinned
model. A model the catalog doesn't list is left unpriced: costUsd is
omitted, never filled at a default rate. A matrix rung with no known
rate is unpriced the same way.
- The catalog warms off the critical path, so rows written before the
first warm completes are unpriced. Call
await warmModelCatalog()(@pleach/core/quickstart) first if you need priced first-turn rows. - An air-gapped route never reads the catalog unless
openrouter.aiis allowlisted. WithPLEACH_MODEL_CATALOG=false, or with noOPENROUTER_API_KEY, every row is unpriced. - A runtime you assemble yourself gets the same pricing by passing
createModelConfigSnapshot()asinstallStandardLoaders({ modelRates }). WithoutmodelRates, only a route to another rung of the family is priced.createPleachRuntime({ modelRates: false })opts out.
Custom quickstart streams must dispatch to ctx.resolvedModel. A
providerStream you pass to the quickstart receives a context whose
resolvedModel is set on the seam path only when a route was honoured
for that call. When it's present, send the request to that model: the
call is already priced, cached, and audited as it. When it's absent,
pick your model as before.
Per-call rows
Every provider dispatch the runtime issues writes one AuditableCall
row carrying modelCall (ModelCallRecord). That covers every seam
call (converse, reasoning, synthesize, utility), each in-seam
retry and recovery, and the tool-loop's own dispatch. A turn that makes
seven model calls writes seven per-call rows, whatever matrix rung each
one resolved to. One exception: a host streamWithProviderFallback
that cascades across providers inside one stream gets one row for the
whole cascade, unless it declares auditHooksEveryAttempt: true and
calls the auditModelCallAttempt hook on every attempt
(checkProviderFallbackAttemptConformance in @pleach/core/testing
checks that it does).
Declaring it is a promise about the stream. Forward each attempt's events unchanged, before you advance that attempt again. A synthetic aggregate terminal, rewritten finish reasons or token counts, events yielded between attempts, or buffered and replayed events keep the outer row beside the per-attempt rows, so the call counts twice. The ledger can't see an attempt dispatched without the hook or an unhooked attempt whose events stand in for a hooked attempt's. Covering those is the implementation's job.
Every hooked attempt records its own row, read or not. An attempt
created but never read records errorClass: "unread", and one created
after the call settled records "post-settle". Neither counts as a
provider failure, and both omit cost (usage-unreported) rather than
record $0. See
the AuditableCall row → fallback attempts.
The ledger now holds two kinds of row:
| Row | What it records | Carries |
|---|---|---|
| Decision row | A choice the runtime made: a plan, a tool selection, a provider cascade, a synthesis-quality check | The decision payload, plus tokenCost when the decision's usage arrived |
| Per-call row | One dispatch to a provider | modelCall: requested and served model, call class, attemptIndex, outcome with a closed errorClass, reported tokens, costUsd when known, latency |
A per-call row's parentRecordId points at the decision row its own
dispatch recorded earlier in the turn, and is omitted when there was
none. The row never carries prompt, response, or provider error text.
Each dispatch is billed once. When a decision row describes the
same dispatch as a per-call row (same turn, stage, model and total
input and output tokens), the per-call row owns the cost. The decision
row then omits tokenCost.costUsd and says why:
priced-per-callwhen the per-call row carries the cost;owned-per-callwhen the per-call row is itself unpriced, so a cost-unknown count counts the dispatch once.
A decision row with no matching per-call row is still priced, so no dispatch is left without an owner. See Observe → unknown cost for every reason a cost can be omitted.
Per-call rows are on by default through createPleachRoute,
createPleachAgent and the sidecar. AuditEmitter.recordModelCall is
optional, and a host emitter that doesn't implement it writes no
per-call rows. Both slots are additive in audit record version 27 and
live in the Postgres ledger's payload JSONB, so no migration is needed.
Version 28 adds priceSnapshot beside costUsd on modelCall and
tokenCost: the id, generation and fetch time of the price snapshot
the cost came from. See
the AuditableCall row → price snapshot.
A call whose usage wasn't reported is never priced at $0. From
version 30 (Unreleased), a per-call row whose stream reported no usage,
only one of the input and output counts, or 0 for both omits
costUsd and sets modelCall.costOmitted: "usage-unreported". The
only unmarked absence is an errored attempt that streamed nothing but
error or terminal events (a refusal). A streamed call that errors
after its provider sent a usage object, even usage: {}, is marked. A sub-agent's inner call that
has no per-call row of its own carries the same reason as a top-level
costOmitted on its decision row (version 28). See
the AuditableCall row → unreported usage.
Cross-family fallback policy
The runtime does not silently widen across families when the
session's locked family is exhausted. Once every in-family rung is
tried, the runtime surfaces a family-exhausted state to the host.
Tool-call dialects differ by family, so the lock keeps one conversation
on one dialect. A change of family is an explicit step by the
host, which it can hand to the user.
A model that doesn't resolve through the matrix at all — a BYOK slug,
a gateway alias, an unrecognized id — has no family to walk, so it
keeps the served model. The recoveries end the turn on it with neutral
copy, and the hallucinated-tool and repetition retries re-stream it at
most sameModelRetryCap times per turn (default 3, set on
createPleachRuntime). Such a turn's llm.turn row stamps
run.model_pivot: "none". The legacy cross-family fallback for these
models is opt-in only, through the deprecated legacyNonMatrixFallback
option, and is removed in 1.0.0. A failure to load the model-family
helpers never switches model either, for any family. See
Family-locked routing.
Where to go next
Family-locked routing
One ProviderFamily and one Transport lock at session start, freezing tokenizer, prompt-cache key, tool-call dialect, and refusal pattern. The cascade walks in-family rungs only.
Session lifecycle
How a session is minted, persisted, resumed, aborted, time-traveled, and deleted — the unit of identity that outlives any single turn.