AI and LLMs in production

Integrating AI and LLMs Into Production Products: An Engineering Leader's Guide

Practical patterns for shipping AI features in production — from prompt engineering to cost control, evaluation, and team upskilling.

On this page
  1. Start with the Problem, Not the Model
  2. The Prompt Engineering Stack
  3. Cost Control Is an Engineering Problem
  4. Evaluation: The Hardest Part
  5. Latency Budgets for AI Features
  6. Team Upskilling
  7. What I’d Do Differently
  8. The Bottom Line

The gap between an impressive AI demo and a production AI feature is enormous. I’ve spent the last two years integrating LLMs and AI capabilities into real products, and the engineering challenges look nothing like what the tutorials suggest.

This is a practical guide for engineering leaders who are past the hype and need to ship AI features that are reliable, cost-effective, and actually useful to users.

Start with the Problem, Not the Model

The most common failure mode I’ve seen: a team gets access to GPT-4 and starts looking for problems to solve with it. This is backwards.

The right sequence:

  1. Identify a user problem that involves language understanding, generation, or reasoning
  2. Define what “good enough” looks like — what accuracy, latency, and cost constraints exist?
  3. Evaluate whether an LLM is the simplest solution (sometimes regex and heuristics win)
  4. Only then choose a model

We killed two AI feature proposals early because the problem was better solved with search + templates. Saved months of development time.

The Prompt Engineering Stack

In production, prompts aren’t strings — they’re versioned, tested, and monitored artifacts.

Our layered approach:

System Prompts as Configuration

Store system prompts in version control alongside the code. Treat prompt changes like config changes — they go through PR review, have rollback capability, and are tied to specific model versions.

Structured Output Contracts

Never rely on free-form LLM output in production. Use structured output (JSON mode, function calling, or Zod schema validation) to guarantee the shape of what you get back.

const schema = z.object({
  sentiment: z.enum(['positive', 'negative', 'neutral']),
  confidence: z.number().min(0).max(1),
  reasoning: z.string().max(200),
});

const result = await callLLM(prompt, { responseFormat: schema });

If the LLM returns something that doesn’t match the schema, you catch it immediately rather than propagating bad data downstream.

Fallback Chains

No single LLM call should be a single point of failure:

  1. Try the primary model (e.g., GPT-4o)
  2. On failure/timeout, fall back to a faster model (e.g., GPT-4o-mini)
  3. On total failure, return a graceful degradation (cached result, human handoff, or explicit “unavailable” state)

Cost Control Is an Engineering Problem

LLM API costs can spiral quickly. At scale, the difference between a well-optimized and naive implementation is 10–50x in monthly spend.

Patterns that control cost:

  • Prompt caching: If the same or similar queries recur, cache responses. Even a 1-hour TTL dramatically reduces API calls
  • Model routing: Not every request needs GPT-4. Use a lightweight classifier to route simple queries to cheaper models
  • Token budgeting: Set hard limits on input/output tokens per request. Truncate context intelligently rather than sending everything
  • Batch processing: For non-real-time tasks (content moderation, classification), batch requests to reduce overhead

We reduced our monthly LLM spend by 65% by implementing model routing alone — most requests were simple enough for a smaller model.

Evaluation: The Hardest Part

Traditional software testing doesn’t work for AI features because the output is non-deterministic. You need a layered evaluation strategy.

Our evaluation pyramid:

Unit-Level: Deterministic Checks

For structured outputs, validate the schema. For classifications, maintain a labeled test set and run assertions on known inputs. These catch regressions quickly.

Integration: Human Evaluation Samples

Weekly, sample 50–100 production outputs and have domain experts rate them on a rubric. Track quality scores over time. This catches subtle degradation that automated checks miss.

System: A/B Testing

When rolling out a new model version or prompt change, A/B test it against the current version with real users. Measure task completion rate, user satisfaction, and downstream business metrics — not just output “quality.”

Latency Budgets for AI Features

Users have different latency expectations for different interactions:

Interaction Budget Strategy
Autocomplete/suggestions < 200ms Use a small, fast model or cached results
Content generation < 3s Stream tokens to show progressive output
Analysis/report < 10s Show a loading state with progress indicators
Background processing Minutes Process async, notify when complete

Streaming is your best friend for generation tasks. Showing tokens as they arrive makes a 5-second generation feel like 1 second because the user starts reading immediately.

Team Upskilling

Your existing engineers can build AI features — they don’t need to become ML researchers. But they do need new skills.

What I’ve invested in for my team:

  • Prompt engineering workshops: 2-hour sessions where engineers practice writing and iterating on prompts for real use cases
  • Cost awareness training: Every engineer should be able to estimate the API cost of a feature before building it
  • Evaluation mindset: Shift from “does it work?” to “how often does it work, and what happens when it doesn’t?”
  • Pair programming with AI tools: Using Copilot/Cursor effectively is a skill. Dedicate time to learning it

The engineers who thrive in AI product development aren’t necessarily the ones who know the most about transformers — they’re the ones who think clearly about edge cases and failure modes.

What I’d Do Differently

Looking back on our AI integration journey:

  1. I’d start with evaluation infrastructure before the first feature. Retrofitting evaluation is painful
  2. I’d budget 40% of development time for edge cases. The happy path is 20% of the work
  3. I’d resist the pressure to use the biggest model. Start small, upgrade only when the smaller model measurably fails
  4. I’d involve product and design earlier. AI features need different UX patterns (uncertainty indicators, feedback loops, graceful degradation)

The Bottom Line

AI and LLMs are powerful tools, but they’re tools — not magic. The engineering fundamentals still apply: define requirements, build incrementally, test rigorously, monitor in production, and optimize based on data.

The teams that succeed with AI in production are the ones that treat it with the same engineering discipline they apply to everything else.


I’m building AI-powered features in production and helping teams adopt LLMs effectively. If you’re exploring AI integration, reach out.

Hashan Jayalath
Hashan Jayalath

Full-stack and AI lead at Allsopp & Allsopp in Dubai, where he runs a production multi-agent AI platform. Before that he was technical lead on a UAE stock exchange app at Nagarro. 10+ years building cloud systems in fintech, insurance and real estate. More about Hashan · Get in touch.

Keep reading

↑↓ move · Enter open · Esc close