Prism
Every routing rule published, every one of them verifiable
This page documents the routing rules in full technical detail.
Four layers, from fully manual to fully managed
All four share one trace format. Whichever layer handled it, any request can be replayed to show why that model was chosen.
| Layer | What it does | Who it's for |
|---|---|---|
| Named model | Put a specific model ID in the field and Prism stays out of it entirely. | Users who already know which model they need. |
| Prism auto | The default policy we maintain and keep tuning, active as soon as you connect. Starts on a fast, low-cost tier and steps up automatically for harder tasks; send auto-max if you prefer per-turn difficulty scoring that rounds up near boundaries. | Users who prefer not to configure anything. It's the default for new accounts. |
| Custom model | Write your own rules, save them under a name, call it like a model. | Users with a predictable task distribution who want fine-grained cost control. |
| Failover | The backstop beneath all three. Moves to a same-tier backup when a model is unavailable. | All users. On by default, can be turned off; backups are picked within the same tier, not chosen by you. |
Adjust the distribution and see the result
All four weights are adjustable and normalise as you drag. They use the coefficients published at /models.
The multiplier is the weighted result of your distribution and the published coefficients — check it yourself against /models. Your real distribution is recomputed monthly by the console from actual usage.
How difficulty is judged
The classifier runs before the request reaches a model within a latency budget under 15ms using local rule scoring. The table below lists the per-turn signals scored by auto-max; see the note beneath for how default laddered auto steps up.
| Signal | What it tells us |
|---|---|
| Input token count | A long context usually means a more involved task. |
| Whether tools are declared | Requests carrying tools are usually agent work, where there's little room for error. |
| Conversation depth | Accumulated multi-turn work is generally harder than a single turn. |
| Code block count and length | Separates "what's the syntax" from "rewrite this module". |
| Intent keywords | Refactor, design, debug, translate and format differ enormously in difficulty. |
| Explicit request header | X-AGIPlan-Difficulty overrides the automatic judgement outright. |
**Three-tier ladder (default auto)**: every conversation starts on a fast, low-cost tier — a plain question goes to the fast group; agent sessions with tools, or messages asking to refactor / design / debug or carrying large code blocks, start in the balanced group; an explicit difficulty header is followed as declared. The conversation steps up one tier when the same turn is resent unchanged, when the previous turn was cut off mid-stream, or when tool results report errors three turns in a row — up to the frontier group, staying there for that session and returning to the starting tier after an hour of inactivity or when the conversation context resets. Only this metadata is inspected; tool output content is never read.
Three hard constraints, not settings
Lower cost must not come at the expense of capability. These three rules are fixed in code, and no custom model or policy can bypass them.
- 01
Short on capability means up, never down
When the chosen tier can't provide a capability the request declares (tools, vision, long context), we only look at stronger tiers and bill the tier it lands on; for auto-max, difficulty that lands near a threshold always rounds up. Only when every stronger tier is unavailable right now does auto fall back to a cheaper one to finish the request, and the trace says so.
- 02
Capability requirements filter before cost
When a request declares tool use, vision or a minimum context length, models that can't serve it are excluded and never enter the cost comparison.
- 03
Compliance is not an optimisation
Models without a mainland China filing are not served to users in mainland China. The route is excluded at admission — not relaxed because there is no alternative, and not allowed through because your custom model names it.
Failover and billing
Model outages happen regularly. Failover is on by default, stays within the same capability tier, and failed attempts are never billed.
5xx, rate limits, timeouts, credential failure
First-token timeout starts at 60 seconds and widens with input length (15 seconds more per 50k input tokens, up to 180 seconds); once a route has enough first-token samples it is tightened to that route's own track record, never below 20 seconds. Send x-agiplan-first-byte-timeout-ms to shorten it — no lower than 5 seconds and no higher than that ceiling. This applies to streaming requests only: a non-streaming request returns only once generation is done, so it is bounded by the 10-minute total limit instead. Truncated output that wasn't your intent is logged but never auto-retried — auto-retry would double-bill.
Same capability tier only
We switch only within the tier you chose and never across tiers to a cheaper one. Within the tier we prefer the higher-quality model, so a failure can land you on a slightly lower-ranked one; every response carries `x-agiplan-model-actual`, so you can always check which model served it. A custom model policy can turn failover off (failover.enabled = false), in which case a model failure returns an error.
Return an error rather than downgrade
If no model in the tier is available, the default is a 503 with the full record of attempts; a weaker model is never used instead.
Failures aren't billed; after a switch you pay the serving route's rate
Only the attempt that returns is metered; failed attempts during switching are not billed. After a switch you pay the rate of the route that actually served you, and the bill names both the original model and the serving model; where the initial route was cheaper, the call trace shows both figures. If you'd rather not be billed on another route, turn failover off or set your key to "Cost". One exception: if the model service drops after the stream has started, output already produced is billed by actual tokens, just as when you abort a request yourself.
"failover": { "enabled": true, // defaults to true "scope": "same_tier" // same_tier only; custom backup order is planned }
Routing traces
Every request has a trace, retained for 30 days and exportable.
- 0msauthap_live_…f3c2 · Pro
- 3msquotareserved 11.742 CU (14,200 in + max_tokens 8,192, worst case), all three windows clear
- 11msprismdifficulty 0.82 · tools=3 tokens_in=14,200 code_blocks=2
- 12msrouterule #1 matched → frontier · model-a
- 14msrespondmodel-a rate limited
- 210msfailoversame-tier backup model-b · billed at model-b's rate
- 224msstreamfirst token 890ms
- 8.42scommitin 14,200 / out 2,130 → 4.970 CU billed, remaining 6.772 CU of the reservation released
Traces hold metadata only, never request bodies, and contain model identifiers only.
X-AGIPlan-Trace
Successful responses carry a trace ID plus X-AGIPlan-Model-Actual naming the model that really ran. Refused responses carry no trace ID, because no usage record was created; on a 503 the chain is in the body as `attempts`.
Expand any usage row
Each line expands into the full timeline. Requests that went through failover are marked so you can filter them directly.
GET /v1/traces/{id}
Fetch it with your own key to get structured JSON, which you can also feed into your own observability stack.
Include the trace_id when reporting a problem
Support can locate the request by ID, so you don't need to describe what happened again.
Custom model policy example
auto and custom models share one rule language: rules are matched top to bottom and the first hit wins; no match falls through to default (or is refused when default is null). Name it, save it, and call it like any model.
{ "name": "my-coding-model", "pools": { "strong": { "tier": "frontier" }, "domestic": { "tier": "domestic" }, "mid": { "tier": "balanced" }, "cheap": { "tier": "fast" } }, "rules": [ { "id": "hard", "when": { "difficulty": { "gte": 0.75 } }, "use": "strong" }, { "id": "zh_long", "when": { "lang": "zh", "tokens_in": { "gt": 8000 } }, "use": "domestic" }, { "id": "medium", "when": { "difficulty": { "gte": 0.35, "lt": 0.75 } }, "use": "mid" }, { "id": "simple", "when": { "difficulty": { "lt": 0.35 } }, "use": "cheap" } ], "default": "mid", "constraints": { "require_tools": true, // models without tool use are excluded outright "min_context": 128000, "max_cu_per_request": 500 // reject anything larger, so one request can't drain the quota }, "failover": { "enabled": true, "scope": "same_tier" } }
Work out how much you can save
The pricing page has an advisor that recommends a plan based on how you work.