Back to Writing

Production

Deploy LLM to Production: A Runbook for Small Teams

Deploy an LLM with a practical small-team runbook: API vs self-hosting, serving stack, eval gates, request costs, monitoring thresholds and safe rollback.

12 min read

Key takeaways

  • Production-ready means four numbers hold above thresholds you set before launch: p95 latency, error rate, eval scores, and tracing coverage.
  • Start with a managed API and only self-host once token spend, latency needs, or data-control requirements justify owning GPU operations.
  • Gate every deploy with a frozen eval set of 50-100 real inputs and numeric thresholds wired into CI so a red run blocks the merge.
  • A RAG request with a 4,000-token prompt, 600 output tokens, and 10% retries costs roughly $0.024, or about $1,200 at 50k requests per month.
  • Rollback only works if models, prompts, and retrieval index are all pinned by version; when a threshold trips, shift traffic back in under five minutes.

To deploy LLM to production without a senior AI hire, work through six steps in order: pick self-hosted vs API, choose a serving stack, set eval gates, calculate cost per request, define monitoring thresholds, and write a rollback procedure. This runbook gives you the decision criteria and the numbers for each step, so your demo survives real traffic without a token bill you can't explain.

What does 'production-ready' mean for an LLM app?

Production-ready means the app holds four numbers above thresholds you set before launch, not that the demo impressed someone.

The four failure modes demos hide

Reliability under real traffic. Concurrent requests expose latency spikes, rate limits, and timeout cascades that a single-user demo never touches. Measure p95 latency and error rate, not the happy path.

Cost per request. A single call to Claude Sonnet with a 3K-token prompt and 500-token output runs about $0.0165 at Anthropic's published pricing. Multiply by your traffic and that's your baseline token bill before retries and eval runs.

Eval scores. Demo quality is one prompt you hand-picked. Production-ready means a scored test set gates every deploy.

Tracing coverage. If you can't see every retrieval hit, tool call, and token count per request, you can't debug regressions.

Closing that gap with limited headcount is exactly the work covered at federicomolina.com.

Self-hosted model or API: which should you pick?

Run four numbers before you decide: cost per request at your projected volume, p95 latency, data-control requirements, and how many engineering hours you can spend on inference plumbing instead of product.

CriterionAPI (OpenAI, Anthropic, etc.)Self-hosted (vLLM on your own GPUs)
Cost per requestPer-token, scales linearly with volumeFixed GPU cost; cheaper only above sustained high volume
LatencyNetwork hop + provider queueControllable, but you own cold starts and autoscaling
Data controlPrompts leave your perimeterFull control; matters for regulated data
Team capacityNear zeroNeeds someone who owns serving, scaling, model updates

When the API wins

You're under roughly a few million tokens a day, your data isn't regulated, and your team is two engineers shipping product. Paying per token is cheaper than paying an engineer to babysit GPUs. Switching costs between API providers are low, so start here and revisit at real traffic levels.

When self-hosting pays off

Your token bill is large and predictable, latency is a product feature, or prompts contain data you can't send to a third party. Then a self-hosted open-weight model on dedicated GPUs beats per-token pricing. If you're unsure which side you're on, the worked cost math in the deployment guides on the blog walks through it.

Which serving stack do you actually need?

Default stack for a 2-20 person team

Pick boring, managed pieces: a hosted inference API for your base model, a thin orchestration layer (LangChain or plain code if your flow is simple), a managed vector database for retrieval, and a tracing tool from day one. Wire eval gates into CI before launch so every prompt or model change runs against a fixed dataset; the Promptfoo docs cover this pattern. This stack is what I deploy by default with clients (about me).

Where teams over-engineer

Three recurring traps. First, self-hosting open-weight models before token spend justifies it; you inherit GPU ops nobody on a 5-person team owns. Second, multi-agent architectures when a single chain with good retrieval passes the same evals. Third, building a custom observability pipeline instead of adopting tracing off the shelf. Run each component through one question: does it pass evals or cut cost per request? If not, delete it.

How do you set eval gates before traffic goes live?

Eval gates turn "the demo looks good" into a number that either passes or fails before a deploy ships. Without them, every prompt tweak, model upgrade, or retrieval change is a guess that real users test for you.

Golden dataset size and composition

Start with 50-100 real inputs, not synthetic ones. Pull them from your own logs, support tickets, or the prompts your team typed during the demo phase. Composition matters more than count: include the 20% of cases that broke in testing, ambiguous requests, long-context inputs, and the edge cases your retrieval layer handles badly. Label each with the correct expected output or a rubric description so scoring is mechanical, not vibes. Keep the set frozen; add to it only when production incidents reveal new failure modes.

Thresholds that block a deploy

Define pass criteria per category, not as one blended score. A practical setup: correctness above 90%, refusal behavior above 95%, latency p95 under your product's budget, and zero critical failures on a small "never do this" subset. Wire the eval run into CI so a red result blocks the merge, the same way a failing unit test does. The long paragraph below is the part most teams skip, and it is the one that makes the gate real:

A gate only works if it can fail a deploy you wanted to ship. That means the thresholds are written down before the run, the scoring is automated, and the person who wrote the prompt is not the person who approves the exception. Run the same eval suite on the current production version alongside the candidate, so you see deltas rather than absolute scores, because a 91% that used to be 93% is a regression even when it looks like a pass. If you cannot state, in one sentence, what result would block this deploy, you do not have a gate; you have a dashboard. Treat any manual override as an incident: log it, review it weekly, and tighten the threshold that made the override tempting. That loop is what keeps eval quality honest as the product changes, and it is the difference between catching a retrieval regression before users do versus reading about it in a support channel.

If you want this wired into your pipeline rather than described, that is the kind of engagement I take on: see my work.

What does a request really cost, and how do you cap the token bill?

Worked cost-per-request calculation

Take a RAG request with a 4,000-token prompt (2,500 retrieved context, 1,500 user/system), 600 output tokens, and a 10% retry rate. At $3/M input and $15/M output tokens, one attempt costs $0.021 ($0.012 input + $0.009 output). Add retries and per-request overhead (embeddings, tracing) and you land around $0.024 per request. At 50k requests/month, that is roughly $1,200. Log every span with standard trace fields so retries and retrieval calls are itemized, not invisible; Langfuse's tracing docs show the fields to capture and how to sample traces to keep logging costs down. Numbers here are illustrative; plug in your provider's current rates.

Four levers that cut spend without hurting quality

  1. Shrink retrieved context. Cut 2,500 tokens to 1,200 with better chunking and reranking; input cost drops ~50%.
  2. Cap output. Enforce max_tokens and stop sequences; rambling completions are the biggest silent leak.
  3. Route by difficulty. Send simple requests to a cheaper model, escalate only on low eval scores.
  4. Cache and sample tracing. Cache identical prompts; sample traces at 10-20% in production.

If your per-request math shows spend concentrated in retries or retrieval, that is an architecture problem, not a pricing problem. This is the kind of audit covered in fractional AI-architecture work.

What do you monitor, and at what thresholds do you roll back?

Tracing: what to log on every request

Log five things per request: the full prompt and retrieved context, model and version, token counts (input and output), end-to-end latency, and the final output plus user feedback signal if one exists. Attach a trace ID that follows the request across retrieval, orchestration, and post-processing so you can see which step broke. Ship traces to a store you can query by version, because a spike means nothing until you can filter it to one prompt template or model build.

Sample aggressively at launch: trace 100% of requests while traffic is low, then drop to 10% once volume makes storage a line item. Keep 100% sampling on errors and slow requests regardless.

Rollback thresholds table

Set numeric gates before launch, not after the first incident. These are illustrative starting points; tune them against your own baseline after a week of real traffic.

  • Latency (p95): alert at 1.5x your baseline, roll back at 2x sustained for 10 minutes.
  • Error rate: alert at 2%, roll back at 5% over 5 minutes.
  • Eval score drift: alert when the daily eval suite drops 3 points below the pre-deploy score, roll back at 5.
  • Spend: alert at 120% of your daily token budget, roll back (or fall back to a cheaper model route) at 150%.

Wire these to the previous model version, not to a fix-in-place. When a threshold trips, flipping traffic back takes minutes; debugging under load takes days.

How do you roll back an LLM deploy safely?

Pin everything: models, prompts, retrieval index

Rollback is only possible if every moving part has a version. Pin the model by exact snapshot (a dated model ID, not "latest"), commit prompts to your repo with semantic tags, and version your retrieval index so a re-embed can't silently change answers. If any of the three floats, your "last known-good config" doesn't exist.

Step-by-step rollback runbook

  1. Freeze the deploy. Stop canary traffic ramp so the bad version gets no new requests.
  2. Shift traffic. Route 100% back to the pinned last-known-good model, prompt tag, and index version via your router config. Keep the change under five minutes.
  3. Verify against evals. Re-run your production eval suite on the rolled-back config and confirm p95 latency and error rates return to baseline before closing the incident.
  4. Post-mortem on the diff. The root cause lives in the delta between the two pinned versions โ€” model, prompt, or index. Fix it there, not in the router.

When do you bring in fractional AI-architecture help instead of hiring?

Hire full-time when AI architecture is your core product problem every week and you need someone owning it for years. Go fractional when you need a specific gap closed, eval gates, serving stack, cost-per-request math, in weeks, not the two to three quarters a senior hire takes to source and onboard. If your demo works but real traffic breaks it, that is a defined engagement, not a role.

How the options compare on the same criteria

Judge every option on three things: has the person shipped an LLM app past the demo stage, can they start this week, and does pricing match a scoped problem. Upwork is cheapest but you filter for production LLM experience yourself. Toptal and A.Team vet for general engineering quality, not agent architecture specifically. The Fractional CTO and Catalant cover broader CTO work beyond AI. I take AI products from demo to production as my whole engagement, so the trade-off is narrow focus versus breadth.

FAQ

Can I deploy an LLM app without a machine learning engineer?

Yes, if you use a managed API instead of self-hosting GPUs. A two-person product team can ship with a hosted inference provider, an off-the-shelf tracing tool, and eval gates wired into CI. Self-hosting is the path that requires dedicated ML or infrastructure ownership, so defer it until token spend justifies it.

How big should my eval dataset be before launch?

Start with 50-100 real inputs pulled from logs, support tickets, or prompts typed during the demo phase. Composition matters more than count: include the cases that broke in testing, ambiguous requests, long-context inputs, and known retrieval failures. Keep the set frozen and add to it only when production incidents reveal new failure modes.

What is a reasonable cost per request to expect?

It depends on prompt and output size, but a worked example: a RAG request with a 4,000-token prompt, 600 output tokens, and 10% retries lands around $0.024 per request including overhead. At 50k requests per month, that is roughly $1,200. Plug in your provider's current rates and log every span so retries are itemized.

What triggers a rollback in production?

Numeric thresholds set before launch, not gut feel. Practical starting points: roll back when p95 latency hits 2x baseline sustained for 10 minutes, error rate reaches 5% over 5 minutes, daily eval scores drop 5 points below the pre-deploy score, or spend hits 150% of the daily token budget. Always flip to the pinned previous version.

How do I make rollback actually work?

Pin every moving part: the model by exact dated snapshot, prompts as semantic tags in your repo, and the retrieval index by version. If any of the three floats, no last-known-good configuration exists. When a threshold trips, shift 100% of traffic back in under five minutes, verify against your eval suite, then post-mortem the diff.

Got an AI system that works in the demo but not in production?

Book a call