Artificial intelligence

AI in production

A known cost per request, a tested security boundary and alerts that fire before users complain.

How we do it

Overview

Once an AI feature is live, it behaves differently from other software in several ways. Its cost varies with every request, depending on how much text goes in and comes out, and its output can change without any deployment, because the provider has updated a model or a source document has changed. It accepts free text from users and from documents, which makes it an entry point for attacks that ordinary input validation does not catch, and the model underneath it will be retired on a date the provider chooses.

Most teams discover these properties one at a time, often starting when the first invoice turns out larger than the business case assumed. A security review then asks what stops the assistant from revealing another customer's data and does not get a clear answer, or users report that answers got worse last month and there is no measurement to confirm or refute it. Each of these is handled as an incident, even though all of them could have been predicted.

We treat the operating side as a separate piece of work. It covers a cost model per request together with the controls that keep spending within it, security boundaries around what the feature can read and send, monitoring that watches quality as well as uptime, and a routine for moving to a new model. The aim is a modest one, which is that the feature that worked at launch keeps working at a cost that still justifies it.

Challenges we address

The failures we are usually called in to fix
  1. Model spend that cannot be explained

    Spend with the model provider rises month after month and arrives as a single figure per API key. Because nobody can say which feature, customer or prompt is driving it, the only control available is a blunt cap that breaks things when it is reached.

  2. The largest model used for everything

    Every request goes to the most capable model, because that is what the prototype used. Classifying a ticket then costs the same per token as drafting a legal summary, and the simple tasks take longer to return than they need to.

  3. Quality drifting without an alert

    Dashboards show uptime and error rates, and both look healthy, while the answers themselves have degraded after a source change or a model update. Since the system returns a successful response every time, the first sign of trouble is usually a complaint from a user.

  4. A deprecation notice with weeks to go

    The provider announces that a model version will be switched off. Because the prompts were tuned to that version's habits and there is no test set to compare a replacement against, the migration turns into an unplanned project.

  5. No boundary around the data

    The feature can read more than it needs and can put what it reads into output, links or tool calls. A single instruction planted in a document can be enough to make it send private content to a place it should never reach.

Our approach

How the work runs, in order
  1. Measure every request

    We instrument the feature so that every request records its model, its input, output and cached tokens, its latency and cost, and the feature and tenant it belongs to. Within a few days this shows where the money goes, which is often a handful of prompts that carry more context than they need.

  2. Cut cost where quality holds

    We trim context, cache the stable prefix of prompts, send work that can wait through batch interfaces and route simple steps to smaller models. Each change is checked against the evaluation suite, so that any saving which lowers quality is caught before it ships.

  3. Draw the security boundaries

    We map what the feature can read, what it can write and where its output can go, and then narrow each of those with scoped credentials, redaction of sensitive fields before they reach the model, checks on output and blocks on outbound destinations that have not been approved. Adversarial cases test these boundaries on every release.

  4. Monitor quality as well as uptime

    Alerts cover spend, latency and error rates, and they also cover quality through scores from the nightly test run, sampled grading of live traffic, refusal rates and user feedback. Every alert has an owner and a runbook entry that says what to check first.

  5. Rehearse the model change

    We pin model versions, track the providers' retirement dates and write the migration routine, which runs the candidate against the test set, compares cost and latency, adjusts prompts, releases to a share of traffic and then switches over. We carry out the first migration together with your team, so that the second one needs no outside help.

Technical capabilities

What we design, build and operate
  • Cost attribution

    Accounting of tokens and cost for each request, tagged by feature, team, tenant and prompt version, with reports that both finance and engineering can read.

  • Prompt and response caching

    Provider-side prompt caching for repeated prefixes, plus application caches for identical or equivalent requests in cases where a stored answer is safe to reuse.

  • Model routing and fallback

    Rules that send each step to the cheapest model that passes its tests, and that fall back to a second model or provider when the first one is slow or unavailable.

  • Gateway and rate control

    One gateway for all model traffic, which holds the keys, applies budgets and rate limits for each consumer and provides a single place to log requests and switch providers.

  • Injection and leakage defenses

    Several layers of control, covering separation of untrusted content, least-privilege access, output checks for sensitive data and limits on links, images and tool calls that could carry data out.

  • Sensitive data handling

    Personal and confidential fields are detected and masked before prompts leave your boundary, and retention settings are applied to any logs that contain user content.

  • Quality and latency monitoring

    Dashboards and alerts for each feature that track evaluation scores, sampled grading of live traffic, time to first token, total response time and error rates.

  • Model lifecycle management

    Pinned model versions, a calendar of upcoming provider retirements and a tested routine for evaluating a replacement model and moving to it.

Where it applies

Business applications
  • Getting a rising bill under control

    Finding out which features and prompts drive spend with the model provider and reducing that spend without a drop in answer quality that users would notice.

  • Passing a security review

    Giving the security team a documented boundary, test evidence covering injection and leakage cases and a log of everything the feature accessed.

  • Planned model migration

    Moving to a newer or cheaper model ahead of a retirement date, with the decision based on a measured comparison of the two models.

  • Multi-tenant AI features

    Running one feature for many customers, with a budget for each tenant, isolation of each tenant's data and usage reports that can feed billing.

  • Taking over a feature after launch

    Putting monitoring, runbooks and a named owner around a feature that was built by a project team which has since moved on to other work.

In practice

Two situations this service is built for, and what we would do in each.

Cross-industry

An assistant whose cost outgrew its business case

The situation
An organization launched an internal assistant on the largest model available, and while usage grew as hoped, the provider's invoice grew faster. Finance wants a forecast, but engineering only has a monthly total per API key, and the fix being proposed is a usage cap that would switch the feature off for part of every month.
What we would build
We would route model traffic through a gateway that tags each request with its feature and prompt version, and then analyze where the tokens go. The likely findings are oversized context and a long system prompt that is sent again with every call, so we would trim retrieval, enable prompt caching for the stable prefix and move classification steps to a smaller model, checking each change against the evaluation suite.
What it is designed to change
Cost would become a figure per request that finance can forecast and engineering can influence. We would track the cost per request for each feature next to the evaluation scores, so that a saving which harms quality shows up straight away.
Education

A student assistant that reads uploaded documents

The situation
A university runs an assistant that answers student questions and can read the documents students upload as well as their enrollment record. The security team wants to know what happens if an uploaded file contains instructions aimed at the model, and whether one student's details could ever appear in another student's session.
What we would build
We would map every data source and output channel and mark uploaded content as untrusted. The assistant's tools would be limited to the signed-in student's own record, with that limit enforced by the record system itself rather than by instructions in the prompt, and output would be checked for identifiers that belong to other students. Rendered links would be restricted to approved domains, and a standing set of adversarial test files would run with every release.
What it is designed to change
The security team would have a stated boundary and evidence that it is tested. On every release we would report the pass rate of the adversarial suite and the number of findings in which one student's data reached another, which should stay at zero.

Technologies

We work in your stack and recommend on fit. We resell nothing.
Gateways and routing
LiteLLM · Portkey · Kong AI Gateway · Cloudflare AI Gateway · Azure API Management · custom proxies
Tracing and monitoring
OpenTelemetry · Langfuse · LangSmith · Arize Phoenix · Datadog · Grafana
Guardrails and data protection
Llama Guard · NVIDIA NeMo Guardrails · Microsoft Presidio · Amazon Bedrock Guardrails · Azure AI Content Safety
Model providers
Anthropic · OpenAI · Google · Amazon Bedrock · Azure AI Foundry · open-weight models
Caching and storage
Redis · PostgreSQL · object storage · provider prompt caching

Business outcomes

What changes for the organization
  • A cost you can forecast

    Spend is known per request and per feature and is covered by budgets and alerts, which turns growth in usage into a planned expense.

  • Security that can be shown

    The reach of the feature is documented and tested against injection and leakage cases, which gives a security review something concrete to assess and sign off.

  • Degradation noticed early

    A drop in answer quality raises an alert within a day, and the alert carries enough detail to tell whether a model change or a data change caused it.

  • Model changes as routine work

    When the provider sends a retirement notice, your own team carries out a rehearsed migration with measured results, on a timetable that you choose.

What you hold at the end

  • A cost model per request, by feature and tenant
  • A gateway with budgets, rate limits and provider fallback
  • Caching and model routing rules with test evidence
  • A security boundary document with adversarial test cases
  • Dashboards and alerts for quality, latency and spend
  • A model migration runbook and retirement calendar
  • On-call runbooks for the most likely failures

Questions buyers ask

The drivers are the tokens going in, the tokens coming out, the price of the model and the number of requests. For features that retrieve documents the input is usually the larger part, because each request carries instructions, retrieved passages and conversation history, and agents multiply this because every step sends the growing context again. The controls that work follow from that, which means sending less context, caching the part that repeats, using a smaller model where it passes the tests and batching work that needs no immediate answer.

They are different things. Prompt caching is offered by model providers, and when requests share a long identical prefix, such as a system prompt or a reference document, the provider reuses its processing of that prefix and charges less for it, while the model still generates a fresh answer. Answer caching stores a complete response and returns it for a repeated request without calling the model, which saves more but risks serving something stale or meant for another user, so the cache keys need care.

Largely, with some discipline. Keep prompts, tools and tests in your own repository, call models through a gateway or a thin interface of your own, and maintain an evaluation suite that can score any candidate. Prompt tuning does not transfer for free, since a prompt adjusted for one model often needs rework for another, so lock-in comes down to days of testing and stops short of a rewrite. A second provider kept tested as a fallback is reasonable, whereas splitting live traffic across two permanently doubles the prompt maintenance.

We score outputs continuously. The evaluation suite runs every night against fixed cases, which catches changes caused by models, prompts or data, and a sample of live traffic is graded automatically against a rubric while a smaller sample goes to human review. We also watch indirect signals such as refusal rate, answer length and how often users rephrase or reject a draft, and a shift in any of them raises an alert before complaints build up.

We can, although we do not assume it. Normally we set up the controls, run them alongside your team for a period and hand over with runbooks. If you would rather not staff it yourselves, our managed operations service covers monitoring, on-call, cost reviews and model migrations on a month-to-month basis with a principal accountable, and because the setup is identical either way, you can take it back whenever you choose.

Discuss AI in production with the people who would do the work.

Tell us what you are trying to do and where it is stuck. A principal reads every message and replies within one working day.

How we engage

Start a conversation.

A short paragraph is enough. A principal reads every message and replies within one working day.

Or email hello@farside.works. We use what you send only to reply. Privacy