Cost per line of code · October 2026
Our agent writes 100 lines of working, tested code for about 12 cents.
We gave our agent five coding jobs, from a two-line bug fix to a feature spread over three new files, and ran each one three times on Gemini 4 Argon, our default AI model. We counted every line it changed with git, checked every result with tests the agent never saw, and read the exact cost from the AI provider.
- $0.12AI cost per 100 lines changed, across all 15 runs
- 15 of 15runs passed our hidden tests
- ~340lines per Neo Credit Unit (NCU), about 435 on feature work
- $1.70total cost of all 15 runs, 1,444 lines changed
What we found
- Bigger jobs are cheaper per line. A 200-line class cost $0.12; a 2-line bug fix cost $0.06.
- The cost comes from reading, not writing. 97% of what the AI processes is the code and instructions it reads; the code it writes is 3%.
- About two thirds of the lines are tests. We asked for tests on every feature, and the agent wrote them every time.
- Speed: one to three minutes per job.
Where to be careful
- This is a small codebase. In a large one the agent reads more before it writes, so each line costs more.
- Lines are a rough measure of value. The two-line bug fix cost the most per line, yet it stopped discount codes from making orders free.
Bottom line: new code costs cents, not dollars. Price it per job, because a line count says little about what the work was worth.
Full technical write-up, for engineers
Module 08 · Lines of code vs cost · 15 runs, 2026-10-29
1,444 changed lines for $1.70: what each line of agent-written code costs.
Five coding tasks of increasing size, three runs each, on Gemini 4 Argon with medium thinking, the model and settings the app ships. Lines come from git diff --numstat against the starting commit; cost and tokens are what the provider reported. Every run passed hidden checks the agent never saw.
Results by task, median of 3 runs
| Task | Passed | Lines added | Source / tests | Cost | NCU | Cost per 100 lines | Model calls | Time |
|---|---|---|---|---|---|---|---|---|
| L1 · Fix two bugs | 3/3 | 2 (+3 removed) | 2 / 0 | $0.057 | 0.14 | $1.26 | 4 | 53 s |
| L2 · Add one function with a test | 3/3 | 19 | 5 / 14 | $0.072 | 0.18 | $0.44 | 6 | 50 s |
| L3 · Add a coupons module | 3/3 | 78 | 35 / 43 | $0.148 | 0.37 | $0.17 | 11 | 175 s |
| L4 · Add an inventory class | 3/3 | 203 | 64 / 138 | $0.117 | 0.29 | $0.06 | 7 | 118 s |
| L5 · Receipt feature across three modules | 3/3 | 175 | 67 / 108 | $0.147 | 0.37 | $0.09 | 9 | 164 s |
| All 15 runs (totals) | 15/15 | 1,435 (+9 removed) | 526 / 909 | $1.70 | 4.24 | $0.12 | – | 29 min |
Cost per 100 lines is each task's total cost over its total lines changed (added + removed) across its three runs. NCU is cost ÷ $0.40, the metered work in one Neo Credit Unit. Runs of the same task differ: L5 wrote 131 to 219 lines, L3 67 to 104.
Cost does not grow with lines
Median cost per task against median lines added. A hundred times more code cost about twice as much.
An agent run is a loop of model calls, and every call resends the instructions, the files read so far and the conversation. Across the 15 runs the model processed 1.98M tokens, of which only 60,582 (3%) were output, thinking included. The cost follows how many steps the agent takes and how much it reads, so a small fix that needs a test run to confirm still pays for several steps.
In Neo Credit Units
- About 340 changed lines per NCU across all tasks, about 435 on feature work (L3–L5), in this codebase.
- At the $1.60–2.00 NCU price, that is roughly $0.47–0.59 per 100 lines to a customer.
- An everyday coding job here used 0.14–0.37 NCU.
How we measured
- The harness (
run_lines.py) runs each task with OpenHands SDK 1.42.1, the version the agent-server ships, building the agent from the frozen copy of the settings the app sends (the same copy as the chat study: working rules v5, output style, skills). Modelgemini/gemini-4-argon, reasoning effort medium. The browser tool was off. - Each run starts from a fresh copy of a small JavaScript cart service (45 lines of source and tests, two planted bugs) committed to git. After the run every change is staged and counted with
git diff --cached --numstat;node_modules, lockfiles and.gitignoreare excluded, and source (src/) and test (test/) lines are counted separately. Blank lines and comments count as lines. - Each task has a hidden check written before the runs: the agent's own tests must pass, and a separate script calls the new code with inputs the agent was not shown (for example a coupon over the 90% limit, a reservation that must change nothing when one line lacks stock, a receipt total of $58.57).
- Token counts and cost are what Google reported for each call, summed by the SDK.
What could skew this
- A small codebase. In a real repository the agent reads more files before writing, which raises the cost per line.
- Three runs per task. Lines and cost vary run to run; we report medians and totals.
- Lines measure output, not value. The agent decides how much test code to write, and it wrote more tests than code.