Evaluate and operate / Lesson 20 of 24

Privacy, capacity, and cost

Trace data, throughput, retries, and cost across the complete production decision path.

After this moduleYou can enforce a minimal-data architecture and budget capacity and cost per successful decision.

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
01

Customer choice

A support lead enables semantic queue routing for customer tickets.

02

Request or event

A server receives the ticket event and loads only the latest message plus routing facts.

03

Backend behavior

The service applies a reviewed transform, calls Jev under the selected privacy terms, and stores safe decision metadata.

04

Customer sees

The ticket is routed without exposing unrelated account history to the decision path.

05

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 seesApplication doesJev returns
Ticket routed under a published privacy promiseEnforces the selected route, minimizes state, and controls every local copyA typed judgment; it does not certify privacy
Ticket held when ZDR is unavailableTreats no_providers_available as a policy-safe service failureNo semantic answer
Applied diagnosis

ZDR enabled, raw ticket still appears in traces

provider ZDR true · application span includes state.body

The 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.

Saved locally

Complete a production boundary review

Your answers stay in this browser. Write enough that another engineer could continue the investigation.

Knowledge check

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.

Module quiz

0/4 answered

01Why can raw state still leak when provider ZDR is enabled?
02What should happen when a required ZDR route is unavailable?
03What is the useful unit for comparing cost?
04Why should application limits be below the provider context maximum?
Sources and verification notes 6
TypeSafe legal documentspublic-contract

No training on customer requests/responses, purpose-based retention, enterprise ZDR and US hosting. No fixed ordinary-account retention duration established; MCA section 2.3 includes publication and distillation restrictions.

Gateway zero data retentionpublic-contract

Per-request zeroDataRetention option and provider filtering; application logs require their own retention controls.

Gateway live model catalogobserved

Observed typesafe-ai/jev evaluation model, input USD0.000000042/token, free output and ZDR/no-training flags. Context zeros do not establish zero capacity. No inference executed.

HTTP APIpublic-contract

POST /v1/systemone and authenticated GET /v1/models, request/response fields and errors. Prose and schema differ on omitted instructions, null state and one-level Score; course uses conservative valid requests.

Models, limits and pricingpublic-contract

Native jev-latest and jev-preview documented as jev-1.13.0; 64k total and 32k state plus longest question; 250k tokens/second and 1,200 requests/minute; $0.042/million input tokens. Recheck before rollout.

Research reconciliationinferred

Original cross-source analysis records contradictions and unresolved backend, confidence, retention and empirical-performance questions.

Further learning

Optional references

These resources provide public documentation and examples for readers who want them.

DocsGateway zero data retentionDocsTypeSafe models