Minimize the state before it leaves the application
The operating envelope also includes data, capacity, and cost. data minimization: sending only fields needed for the stated judgment and retaining them only as long as needed reduces exposure, tokens, distraction, and debugging ambiguity. A router rarely needs full history, authentication tokens, raw payment data, or unrelated attachments.
Redaction is not a complete privacy architecture. A message can identify a person without containing a conventional secret, and tool arguments may contain the very data a guardrail is inspecting. Document the data classes, lawful purpose, regions, subprocessors, retention, logs, trace exports, caches, replay stores, and human access. Keep API credentials on a trusted server. Browser code must call your authenticated backend rather than embed a provider key.
Review transformations for semantic loss. Replacing every number can remove a charge identifier needed to distinguish a duplicate payment, while leaving free-form organization names may preserve identity. Define field-specific transformations and test both privacy and decision behavior. Access to replay data should be narrower than access to aggregate metrics. A support operator may need a ticket link for correction, while a reliability dashboard usually needs only a decision ID, safe cohort fields, and error category.
function buildRoutingState(ticket: Ticket) {
return {
subject: scrub(ticket.subject),
latestMessage: scrub(ticket.messages.at(-1)?.text ?? ""),
productArea: ticket.productArea,
accountFlags: { supportPlan: ticket.supportPlan },
};
}
Hashing supports correlation but can still expose low-entropy values. Use a keyed digest for safe identifiers, rotate keys deliberately, and keep raw state in an access-controlled system only when an approved replay purpose requires it.
Trace this example from input to result
Customer choice
A support lead enables semantic queue routing for customer tickets.
Request or event
A server receives the ticket event and loads only the latest message plus routing facts.
Backend behavior
The service applies a reviewed transform, calls Jev under the selected privacy terms, and stores safe decision metadata.
Customer sees
The ticket is routed without exposing unrelated account history to the decision path.
Diagnostic reasoning
Trace every copy of the state across application logs, gateway logs, provider processing, caches, replay fixtures, and human tooling.
Read ZDR and retention claims precisely
Vercel AI Gateway currently lists typesafe-ai/jev as ZDR and no-training capable. Setting providerOptions.gateway.zeroDataRetention: true requests a compliant route; current Gateway documentation says failure to find one produces no_providers_available instead of silently selecting a non-ZDR provider. Gateway evaluation calls still appear in logs and custom reporting, so configure application and reporting fields deliberately. ZDR at the inference provider does not erase your own logs.
For the direct TypeSafe API, public materials say customer requests are not used to train or fine-tune models. The public privacy terms describe purpose-based retention rather than a fixed ordinary-account duration. Direct ZDR is documented as an enterprise arrangement. Confirm the account contract before sending regulated or highly sensitive data; do not infer ZDR from a no-training statement.
Write these claims into a data-flow record with source and verification date. "No training" answers how inputs affect model development. "Zero data retention" addresses storage under particular routing conditions. A regional term addresses location. None defines what the application stores, who can view it, or how long source records remain. Use the narrowest supported statement for each boundary.
| Customer sees | Application does | Jev returns |
|---|---|---|
| Ticket routed under a published privacy promise | Enforces the selected route, minimizes state, and controls every local copy | A typed judgment; it does not certify privacy |
| Ticket held when ZDR is unavailable | Treats no_providers_available as a policy-safe service failure | No semantic answer |
ZDR enabled, raw ticket still appears in traces
provider ZDR true · application span includes state.bodyThe privacy failure is in local instrumentation. Verify provider routing separately, remove body capture from spans, delete improperly retained records according to the incident process, and add a test that inspects emitted telemetry. Do not disable the ZDR requirement to make the symptom disappear.
Plan capacity as an end-to-end budget
Current direct limits are documented as dynamic: 250,000 tokens per second and 1,200 requests per minute at the research snapshot. Treat them as current constraints, not durable entitlements. A request also has a 64k budget across state and all questions and a 32k budget for state plus the longest question. Enforce lower application limits so malformed or unexpectedly large tickets cannot consume the entire boundary.
Capacity depends on arrival rate, token size, concurrency, latency, retries, and review fallback. Batching independent questions reuses state ingestion and round trips, but additional questions still consume tokens. Cache only when state, question, model, and policy semantics make reuse valid. Deduplicate identical in-flight decisions and invalidate when ticket state changes.
Forecast ordinary load, burst load, and incident load separately. An incident can increase ticket arrivals while provider latency also rises, which expands concurrency and queue age at the same time. Reserve capacity for safe fallback writes and human review; otherwise the designed fallback fails exactly when invoked. Record request tokens by percentile, because a stable average can hide a long tail that consumes token-per-second limits.
Use load tests with synthetic fixtures and mocked provider timing when contract terms restrict service benchmarking. Test queue saturation, burst admission, 429 handling, 529 overload, deadlines, and recovery. Never omit failures from throughput calculations. A system that completes 100 requests quickly and silently drops 20 is not faster.
const cacheKey = digest({
stateHash,
questionVersion: "routing-v7",
requestedModel: "typesafe-ai/jev",
});
Dig deeperWhy a context limit is not a target+
Filling the model window increases tokens, distraction, privacy surface, and latency. Retrieval quality should be measured independently: determine whether the needed evidence entered state, then judge whether Jev interpreted it correctly. If state is too large, use deterministic filters or a staged retrieval process. A second request is justified when the first result determines what evidence must be fetched, not merely because the first request was poorly scoped.
Measure cost per successful decision
Current native pricing is documented as $42 per billion input tokens, with output tokens free; Gateway exposes the corresponding per-token rate. Prices can change, so read current billing sources before forecasting. Model tokens are only one cost. Include gateway fees if applicable, network and worker time, retries, failed requests, observability, review labor, corrections, and downstream escalations.
For a synthetic example, suppose 10,000 decisions use 900 input tokens each. The model-input calculation is nine million tokens multiplied by the current rate. Then add every retry and the review load. Label the result synthetic; it is not live traffic or a promise of savings. Compare policies by cost per correct and safely completed route, not cost per API response.
Budget controls should cap tokens per event, attempts per logical decision, daily spend, and queue growth. Alert on changes in average state size, retry multiplication, and review rate. A cheaper threshold that causes wrong routes can increase total support cost.
Allocate ownership for each budget. Engineering owns technical caps and retry amplification, finance verifies current rates and invoices, security owns data terms, and support operations owns review capacity and correction cost. Reconcile forecast with observed usage on a fixed schedule. When cost moves, decompose volume, state size, question count, retries, and price instead of assuming the model rate changed. That decomposition identifies whether to improve retrieval, batching, reliability, or commercial planning.
Complete a production boundary review
Your answers stay in this browser. Write enough that another engineer could continue the investigation.
Check your understanding
Trace data and cost across the complete decision path, enforce privacy and capacity in code, and distinguish ZDR, no-training, local retention, and safe logging.