Budget for accepted work, not impressive demos

A prototype may produce a useful answer from a carefully selected prompt. A production service must handle concurrent requests, incomplete input, permission boundaries and dependencies that occasionally fail. Its cost includes the work required to recognize and correct bad results. A cheap request that creates a long review queue can be more expensive than a higher-priced model that meets the task’s acceptance criteria more consistently.

Choose a unit the business recognizes: an accepted document extraction, a resolved internal query or a reviewed CRM draft. Track total operating cost divided by accepted outcomes for a defined cohort. Keep quality and coverage beside that ratio so rejecting difficult tasks does not masquerade as an efficiency improvement. Scalera Agency’s practical approach to business AI starts with a bounded workflow; this article addresses what it takes to operate that workflow after the pilot.

Make the token calculation inspectable

Input tokens include instructions, conversation context, retrieved passages and tool results. Output tokens include generated responses and, depending on the provider and model, other billable categories described in its pricing terms. Measure actual usage rather than estimating from document length alone. Separate cached input, uncached input and output where the provider bills them differently. Tool charges, retrieval services and reserved capacity may add separate costs.

If hypothetical retrieval costs CAD $30, hosting CAD $40 and human review three hours at an assumed CAD $50 per hour, the illustrative operating subtotal becomes CAD $304. If 9,000 tasks are accepted, that is about CAD $0.034 per accepted task. Development and governance remain additional costs. Replace every assumption with your measured workload and contracted rates; these figures predict neither actual invoices nor savings.

Route models by measured task requirements

Evaluate a smaller model on a narrow classification task before assigning every request to the largest available model. Route by explicit criteria such as document length, supported language, required tools or failure of a validation check. Avoid treating a model’s self-reported confidence as a calibrated probability. Compare routing policies on a held-out evaluation set and monitor the distribution of easy and difficult requests over time.

A provider abstraction can normalize timeouts, usage reporting and a limited response interface. It cannot make providers semantically interchangeable. Schema support, tool behaviour, retention policies and refusal handling can differ. A fallback needs its own evaluation and data approval. Do not forward confidential material to a second provider merely because the first timed out. For high-consequence tasks, an honest unavailable response may be better than a lower-quality fallback.

Reduce repeated work without mixing users

Prompt caching can reduce repeated-prefix processing under a provider’s supported rules. Response caching reuses an application result and creates a stronger correctness obligation. Include tenant, authorization scope, source version and relevant model or prompt version in the cache key. Expire entries when source information changes, and avoid caching personal or sensitive responses without an explicit retention decision. A cache hit that leaks another customer’s answer is a system failure.

Control output length through the task contract and omit irrelevant context before tuning infrastructure. Streaming can improve perceived responsiveness, but it does not make an unvalidated answer safe to act on. Parallelize independent lookups only when their combined load fits service limits. Measure end-to-end latency, including queue time and human handoff, rather than optimizing a model timer while the user waits elsewhere.

Bound every retry and queue

Set a deadline for the user-facing operation and shorter budgets for its dependencies. Retry only transient failures within the remaining budget, using backoff and jitter. Honour rate-limit guidance and cap concurrent requests to prevent a burst from overwhelming the provider. A retry storm can multiply cost precisely when the system is least healthy. Record how much of the accepted-outcome cost comes from retries and discarded generations.

Long tasks need a background queue, a visible pending state and a way to cancel or escalate. Bound queue age and move repeatedly failing work into an operator queue. Use idempotency for external writes; generating a replacement answer is different from repeating a payment or CRM update. Circuit breakers and load shedding protect the wider application when a dependency fails. Test the manual fallback while the service is healthy, rather than inventing it during an incident.

Treat generated content as untrusted input

Prompt injection can arrive inside a customer message, retrieved document or tool response. A model may confuse that material with an instruction. Separate trusted configuration from retrieved content, but do not rely on delimiters or a warning prompt as a complete defence. Limit tool authority, validate each request in server code and require approval for consequential effects. Structured outputs validate shape; they do not establish truth, authorization or freedom from malicious intent.

Minimize data sent to providers, choose retention settings deliberately and review where documents, logs and caches persist. Keep credentials in server-side secret storage. Allowlist tool destinations and prohibit arbitrary shell commands or URL fetching unless the product explicitly requires them and provides suitable isolation. Redact sensitive traces and test cross-tenant disclosure. These controls should match the system’s actual data and permitted actions, not a generic label of enterprise-grade security.

Make quality and cost regressions release criteria

Keep a versioned evaluation set covering normal work, unsupported requests and adversarial cases. Compare correctness, refusal behaviour, latency and cost before changing a prompt, model or retrieval component. Run deterministic validation tests alongside model evaluations. Model outputs vary, so record uncertainty and repeat strategically rather than presenting one favourable run as conclusive. Release gradually and retain a known configuration for rollback.

An operating dashboard needs a decision owner

Connect traces across the request, model call, retrieval stage and tools. Metrics show rates and distributions; logs preserve selected events; traces connect the path through dependencies. Assign an owner to alerts for growing queues, spend anomalies and increased human corrections. Total cost of ownership also includes onboarding, security review, evaluation upkeep and incident response. For a Toronto business planning an AI integration, those responsibilities deserve a budget alongside implementation.

Further reading