Insight
AI in production: cost, latency, and safety rails
What changes when an AI feature leaves the demo — token bills, p95 latency, prompt injection, data leakage, and the controls that keep it shippable.
- AI
- Production
- Security
- Software
Framing note: Production operations for AI features inside web products. Illustrative TriXCore guidance for teams moving past the pilot.
A pilot that “works on our docs” is not production. Production means someone else’s data, your invoice, and your reputation when the model invents a policy.
Cost is a product constraint
Token spend scales with users, retries, and context size.
- Cap max tokens and context per request
- Cache embeddings and repeated system prompts where safe
- Route simple cases to cheaper / smaller models; reserve large models for hard paths
- Alert on spend anomalies the same way you alert on error rate
- Give every feature a monthly ceiling and a degrade mode when hit
If finance discovers the bill first, the feature was never instrumented.
Latency users feel
p50 demos hide p95 pain.
- Stream tokens for long answers so the UI feels alive
- Set hard deadlines; return a partial or fallback when the model is slow
- Precompute what you can (summaries, classifications) on write, not on every page load
- Measure end-to-end: network + retrieval + model + your post-processing
A correct answer after eight seconds often loses to a good-enough answer in one.
Safety rails that belong in code
Do not rely on “the model usually behaves.”
- Prompt injection: treat retrieved docs and user text as untrusted; never let them redefine tool permissions
- Tool use: allowlist tools; confirm irreversible actions with a human
- Data leakage: tenant isolation in retrieval; strip secrets before they enter context; log redaction
- Output validation: schema-check structured outputs; block disallowed categories before UI render
- Abuse: rate limits per user / IP; quarantine runaway agents
Security review for AI features is still web security — plus a nondeterministic component that talks to the internet on your behalf.
What “shipped” means for AI
- Eval suite green on a prod-like set
- Kill switch and non-AI path tested
- Logging of model version, prompt version, and outcome (with privacy rules)
- On-call knows how to disable the feature without taking down the whole app
- A written incident playbook for “model returned harmful / wrong / leaking content”
We ship AI solutions into production with the same ops bar as any other backend — because that is what users and auditors will hold you to.