← All articles

Practical guide · · By Raz Dagan

How to measure LLM-to-code savings without hiding fallback costs

Build a before-and-after cost comparison that includes eligible traffic, provider fallbacks, infrastructure and evaluation work.

Choose one task and one denominator

A cost comparison needs a stable unit of work. Pick one transformation at one call site and count completed tasks, not just provider requests. A task may create several requests through retries or fallback. If you compare requests before the change with tasks after it, the apparent improvement can be misleading.

Record a baseline window with task volume, provider usage, errors and response time. Keep the input contract and quality criteria visible. A lower bill is not a useful outcome if the replacement silently drops required fields or changes the business decision.

Calculate the baseline from observed usage

For a fictional workload, suppose 10,000 completed tasks generated 11,000 provider requests because of retries. Use the actual token usage and the applicable provider price for those requests, then divide the measured cost by completed tasks. These figures are an illustration, not a ModelGate customer result.

Separate one-time experiments from ordinary operation. A spike caused by a replay or a load test should not be presented as the normal baseline. Keep the reporting period and exclusions beside the total so another engineer can reproduce the calculation.

Count eligible traffic and fallbacks separately

After integration, count how many tasks qualify for the deterministic function, how many it completes, and how many still reach the provider. Unsupported inputs, timeouts and explicit rejections may need different handling. Define those categories before reviewing the cost result.

For example, if only half the traffic fits the supported contract, a near-zero provider cost on that half does not imply the whole workload is free. Keep provider costs for ineligible traffic, fallback requests and retries in the after total. Shadow comparisons can temporarily increase usage and should be recorded as evaluation expense.

Include the costs that moved

Code still uses application compute, dependencies and operational attention. Include material infrastructure costs and the engineering effort needed to review, test and maintain the replacement. Distinguish recurring costs from one-time migration work rather than combining them into a single unexplained percentage.

Report quality alongside cost: invalid output rate, supported-case failures, fallback rate and latency. Evaluate the fixed candidate against held-out examples before release and continue checking the contract in production. Agreement with a previous model is useful evidence, but is not proof that every output is correct.

Publish a bounded result

A useful report states the baseline dates, after dates, completed task counts, eligibility, provider cost, additional compute, evaluation expense and quality outcome. Say whether the periods differ in volume or input mix. If they do, report cost per completed task and explain the remaining comparison limits.

ModelGate generates code that runs in your application; Python ports are not executed by ModelGate and need their own testing. Use the documentation and demo to inspect the workflow, then measure your actual deployment. Do not describe projected savings or this fictional example as verified customer savings.

Explore the workflow

Read the code-replacement requirements, GitHub workflow and gateway comparison before deciding.