How AI Coding Startups Improve Gross Margin: Which Lever Fits Your Token Bill, With a Worked Cost Model
Metering, prompt caching, context pruning, model routing and an owned model each move gross margin by a different amount, at a different spend. A guide by situation, priced on Anthropic's list rates.
The fastest way for an AI coding startup to lift gross margin when most revenue goes to Anthropic and OpenAI is to meter frontier usage, so heavy users stop costing more than they pay. The biggest structural gain comes from moving routine tasks to a model you own, post-trained on an open-weight base, the way Cursor built Composer, but only if your serving stack keeps the prompt cache working. Between those sit cache hygiene, context pruning and per-task routing, which pay back at different levels of token spend. On a worked model of a flat-plan agent, the levers together take gross margin from about -18 percent to about 44 percent, with hard turns still going to frontier APIs.
First, read your own bill
A coding agent's bill has a shape that decides which lever matters. Every model call resends the conversation so far, so a 40-call task with a conversation averaging 75,000 tokens bills about 3 million input tokens and perhaps 30,000 of output. Most of that input is a cache read. Anthropic's pricing page lists Claude Opus 5.5 at $4 per million input tokens, $5 for a five-minute cache write, $0.20 for a cache hit and $20 for output; Claude Sonnet 5.5 is half of each.
On those prices, with 95 percent of input read from cache, 3 percent written and 2 percent uncached, an Opus task costs $1.86. Cache reads are $0.57 of it, writes $0.45, uncached input $0.24 and output $0.60. Three numbers in your own logs tell you where you sit: the cache hit rate, the share of tasks that go to the most expensive model, and how much of each prompt is static (system prompt and tool definitions) versus carried history.
For reference, the public margins are thin. TechCrunch reported in April 2026, citing unnamed people, that Cursor had moved from negative to "slight gross margin profitability," profitable on large enterprises and losing money on individual developers. In August 2025 it quoted a person close to Windsurf calling its margins "very negative." Replit has not published a gross margin; the figures that circulate are third-party estimates. CRV wrote in July 2026 that 50 to 60 percent "is defensible today" with a credible path up.
The options, compared
The figures below come from one worked model, described in full in the cost example further down: $100 of monthly revenue, 80 tasks, half on Opus 5.5 and half on Sonnet 5.5, $6 of non-model costs, and a baseline gross margin of -17.6 percent. Each row applies one lever on its own.
| Lever | Cut to token bill, alone | Gross margin, alone | Evidence behind the input |
|---|---|---|---|
| Meter usage above $60 of list price | none (revenue rises) | 22% | Cursor and Replit pricing |
| Cache hygiene (20% fewer cold misses) | 2% | -15% | Cursor, measured |
| Prune carried context by 7% | 7% | -10% | Cursor, measured |
| Route half of Opus tasks to Sonnet | 17% | 1% | List prices; quality untested |
| Owned model takes 60% of tasks, cached | 47% | 35% | Composer list price as stand-in |
If you sell flat plans and heavy users lose you money: meter
This is the first fix because it needs no inference work. Cursor moved in June 2025 from 500 requests a month to "$20 of included usage on Pro," priced at API rates, and its pricing page now says third-party models "remain available in Cursor at API list price," bought separately from plans that pool usage "across Cursor and Grok." Replit replaced a flat $0.25 per checkpoint with effort-based pricing in June 2025, telling users they "may pay more for complex requests."
In the model, including $60 of list-price usage and billing the rest at list turns -17.6 percent into about 22 percent. The pass-through slice earns nothing and loses nothing. The cost is the risk of losing your heaviest users, who were the source of the losses.
If your spend is modest: fix the cache, then the static context
At any spend, check the cache before anything else. Anthropic's documentation says "cache hits require 100 percent identical prompt segments" and that "modifying tool definitions ... invalidates the entire cache." A timestamp in the system prompt or a tool list that varies by user turns cached reads into full-price input. In the model, a fall from 95 to 85 percent hit rate raises the token bill from $111.60 to $180.
Cursor's September 2026 post on token efficiency for longer agent runs is the clearest playbook. Explicit cache breakpoints between stable content and the growing conversation cut cold cache misses by 20 percent. Trimming the system prompt by about two-thirds, loading less-used tools on demand and compressing line numbers in file reads cut users' token costs by 7 percent, which Cursor says came "without reducing agent quality" in A/B tests of cost, latency and tool-call errors. An earlier change to load MCP tools dynamically cut total tokens by 46.9 percent in sessions that called one. None of this needs an ML team.
If your spend is large: prune deeper and route per task
Deeper pruning removes tool output and reasoning the agent will not use again. Every cut changes the prompt, so judge it on the bill after cache effects, not on tokens removed.
Parsec sells this for developers using Claude Code, Codex and opencode. On its own benchmark of 100 SWE-bench Verified tasks, with one model (Claude Sonnet 4.6), the official grader and cache-aware pricing, and only the compression layer changed, cost fell by about 39 percent. It is Parsec's benchmark, not an independent one: the repository publishes per-task results and can be re-run, no independent re-run has been published, and the run recorded a lower cache hit rate with pruning on. Its Pro tier is free to start, according to the site; for a startup's own agent harness, the relevant part is its MIT-licensed proxy and scoring code rather than the packaged product. Parsec also runs a separate custom-model service that post-trains models on a customer's traffic, routes per turn and sends low-confidence requests to a closed frontier model; its routers page claims 60 percent savings without defining a workload or baseline, and it publishes no price.
Routing sends tasks that do not need the top model somewhere cheaper. Replit says its August 2026 routing "delivered the same output quality at 65% lower cost than the previous version of Max Mode," in its own testing with no method published. In the model, moving half the Opus tasks to Sonnet saves 17 percent. Sending 40 percent of tasks to Claude Haiku 5.5, at $0.10 per million input on prompts up to 100,000 tokens, would save 38 percent if Haiku could do them; that has not been measured for coding agents, and Haiku's price is five times higher above 100,000 tokens. Route per task rather than mid-conversation: Anthropic's caching documentation does not mention any way to carry a cached conversation across models, so each switch should be costed as a fresh cache write, about $0.19 for a 75,000-token prefix on Sonnet.
If most of your tasks are routine: own the model
This is what moved Cursor. Its Composer 2.5 post says the model is built on "Moonshot's Kimi K2.5," the open checkpoint also behind Composer 2, and the Composer 2 technical report describes continued pretraining, then large-scale reinforcement learning run in "the same Cursor harness that is used by the deployed model." Cursor prices Composer at $0.50 per million input and $2.50 output.
Cursor has not published Composer's serving cost, so the model uses that list price as a stand-in. With caching at a tenth of input price, an owned-model task costs about $0.30; without caching it costs $1.58, more than a cached Sonnet task. Moving 60 percent of tasks to it saves 47 percent of the bill with caching and adds 8 percent without. The serving stack matters as much as the model.
The build, at a startup's scale, is: pick an open-weight base whose licence fits (Kimi K2.5's modified MIT licence requires products above $20 million in monthly revenue or 100 million monthly users to display its name); collect traces from your own harness; build evaluations from real tasks with a pass signal you already have, such as tests that pass or diffs users keep; post-train; shadow; then A/B test against the frontier model on cost, latency, tool-call errors and continued usage. The check that matters is retention. A cheaper model that makes users retry spends the savings on extra tokens and then loses the customer. The Composer 2 report lists 54 authors, a measure of the effort at Cursor's scale; a smaller team should expect to start with a narrower share of tasks.
If you sell to enterprises or run a platform
Mix and non-model revenue are the remaining levers, and the least quantified. TechCrunch's April report says Cursor is profitable on large enterprises and not on individual developers. Replit sells hosting-side products, including bring-your-own-cloud deployment and databases provisioned at deploy, but does not publish their margin, so their effect cannot be put in the model.
The hard question is supplier power. TechCrunch's April report named Anthropic's Claude Code as Cursor's main rival, so a coding startup buys from the companies it competes with. Cursor's own answer went beyond any of these levers: on August 14, 2026 it announced it "has officially been acquired by SpaceX," citing access to "the largest fleet of GPUs in the world." An independent startup cannot copy that. It can own the model for the tasks it understands best and decide how much of the frontier bill it passes through.
The worked cost example
Assumptions: $100 of revenue from flat plans; 80 tasks a month; each task 3 million input tokens and 30,000 output; 95 percent cache hits, 3 percent cache writes, 2 percent uncached; half Opus 5.5, half Sonnet 5.5 at Anthropic list prices; $6 of non-model cost of revenue; an owned model at Composer's list price with cache reads assumed at a tenth of input.
- Baseline: 40 Opus tasks at $1.86 plus 40 Sonnet tasks at $0.93 is $111.60. Gross margin: ($100 - $111.60 - $6) / $100 = -17.6 percent.
- Cache hygiene, 20 percent fewer cold misses: $108.86, -14.9 percent.
- Plus 7 percent pruning: $101.24, -7.2 percent.
- Plus half of Opus tasks to Sonnet: $84.37, 9.6 percent.
- Plus an owned model on 60 percent of tasks, the remaining 40 percent split 15 Opus and 25 Sonnet: $50.44, 43.6 percent.
Added up one at a time, the same levers would save $81.53 and imply 64 percent. The stack reaches 44 percent because each lever shrinks the bill the next acts on, and routing and the owned model compete for the same easy tasks. With $60 of included usage, metering adds nothing once the bill is $50; it protects the month a customer's usage triples.
When each lever pays back
Payback below compares the saving on a monthly token bill with an assumed $20,000 per engineer-month.
| Lever | Assumed effort | Pays back above (monthly token spend) |
|---|---|---|
| Metering | Billing work, no inference change | Any spend with flat-plan losses |
| Cache hygiene | Engineer-weeks | Any spend; a hit-rate drop costs more than the work |
| 7% context pruning | One engineer-month | About $286,000 |
| Routing half of Opus tasks | Two engineer-months, mostly evals | About $235,000 |
The owned model is left out of the table because its cost is not public: Cursor has not said what Composer cost to train, and the payback depends on that figure and on the share of tasks the model can take.
Bottom line
If flat plans lose money on heavy users, meter frontier usage now. If your token spend is modest, fix cache stability and static context, which need engineers, not researchers. Once monthly spend is in the low hundreds of thousands, fund deeper pruning and per-task routing with evaluations from your own traffic. Own a post-trained model when most tasks are routine and your stack can cache, keeping Anthropic and OpenAI for the hard turns. Plan for a margin in the 40s rather than the SaaS 70s.
Sources
- TechCrunch, Sources: Cursor in talks to raise $2B+ at $50B valuation as enterprise growth surges (April 17, 2026): https://techcrunch.com/2026/04/17/sources-cursor-in-talks-to-raise-2b-at-50b-valuation-as-enterprise-growth-surges/
- TechCrunch, High costs and thin margins threatening AI coding startups (August 7, 2025): https://techcrunch.com/2025/08/07/the-high-costs-and-thin-margins-threatening-ai-coding-startups/
- CRV, LLM inference costs and gross margin: https://www.crv.com/content/llm-inference
- Anthropic, Pricing: https://platform.claude.com/docs/en/about-claude/pricing
- Anthropic, Prompt caching: https://platform.claude.com/docs/en/build-with-claude/prompt-caching
- Cursor, June 2025 pricing clarification: https://cursor.com/blog/june-2025-pricing
- Cursor, Pricing: https://cursor.com/pricing
- Cursor, Cursor is now a part of SpaceX: https://cursor.com/blog/joining-spacex
- Cursor, Improved token efficiency for longer agent runs: https://cursor.com/blog/improved-token-efficiency
- Cursor, Introducing Composer 2: https://cursor.com/blog/composer-2
- Cursor, Composer 2.5: https://cursor.com/blog/composer-2-5
- Cursor Research, Composer 2 Technical Report: https://arxiv.org/abs/2603.24477
- Kimi K2.5 licence: https://huggingface.co/moonshotai/Kimi-K2.5/blob/main/LICENSE
- Replit, Effort-based pricing: https://replit.com/blog/effort-based-pricing
- Replit, Intelligent Model Routing: https://replit.com/blog/intelligent-model-routing
- Replit, Blog: https://replit.com/blog
- Parsec for coding agents: https://parseclab.ai/parsec/
- Parsec, code-compression-bench (Parsec's own benchmark): https://github.com/daseinlabs/code-compression-bench
- Parsec, open-source code: https://github.com/daseinlabs/parsec
- Parsec vs routers: https://parseclab.ai/compare/routers/
- Parsec, Inference: https://parseclab.ai/inference/