Unit economics and finance
COGS vs opex
COGS is the cost of delivering the product to customers. Opex is the cost of building and running the company.
Gross margin is the fraction of revenue left after the direct cost of delivering the product. That direct cost is COGS (cost of goods sold). Everything else — building the product, selling it, running the office — is opex. Mix them up and every later ratio on the P&L lies.
Gross profit = Revenue − COGS
Gross margin = Gross profit / RevenueConcept
If turning off a customer would eventually remove the cost, it is usually COGS. If the cost exists whether you have 10 or 10,000 customers this month — core engineering salaries, the CEO, the office — it is opex. Grey areas exist. Be consistent quarter to quarter.
Walking through a SaaS P&L
| In COGS | Usually opex |
|---|---|
| Cloud hosting and compute for production | Core product engineering (R&D) |
| Third-party APIs required to deliver the product (LLM APIs, SMS, maps) | Sales and marketing |
| Payment processing fees | General and administrative |
| Customer-facing support tightly tied to delivery | Brand marketing, PR |
| CDN and bandwidth for the product | Recruiting for R&D |
| Licensed software embedded in the service | Office, legal, finance |
Support is the classic grey area. Many SaaS companies put technical support in COGS and success / account management in S&M. AI companies almost always put inference in COGS — correctly.
A kitchen picture: flour and the cook's time for this plate are COGS. The rent on the restaurant and the recipe R&D are opex. The analogy breaks on shared infrastructure — a database serves every customer — but the test still holds: would the cost fade if that customer left?
Why the line matters
Gross margin sets the ceiling on operating margin. A company at 80% GM can spend 40 points on S&M, 20 on R&D, 10 on G&A and still show a path to 10%+ operating profit. A company at 50% GM that spends the same opex percentages is structurally loss-making until it cuts or reprices.
Even at healthy margins, the dollars add up. A company at $50M ARR with 75% instead of 80% GM leaves $2.5M / year on the table (0.05 × 50,000,000). That is several senior engineers.
Common mistakes
- Putting inference in R&D so the AI product looks like 80% SaaS. Peers who book it correctly are not comparable.
- Moving COGS into R&D before a fundraise to inflate gross margin. Auditors and good VCs notice.
- Comparing marketplace GM on GMV to SaaS GM on subscription revenue. Ask: margin on what revenue definition?
Check yourself
- A new customer means more LLM tokens and a Stripe fee. COGS or opex? COGS — both scale with serving that customer.
- You hire two core product engineers. COGS or opex? Opex (R&D). Building the product is not delivering it.
Key takeaways
- COGS is the cost of delivering. Building the product is R&D opex.
- Gross margin = (Revenue − COGS) / Revenue.
- The classification test: would the cost go away if the customer did?
- Be consistent. Grey areas (support) are fine if they do not move around.
Further learning
How this number behaves for AI products: inference as COGS.
Related
Gross margin and COGS, including AI
What belongs in COGS vs opex, why classic SaaS runs ~75–80% gross margin, why AI products often sit at 50–60%, and the levers that move the number.
The P&L for startups
Reading and building an income statement — revenue recognition, COGS, S&M / R&D / G&A, EBITDA and net income — with a worked $5M ARR SaaS example.
Unit economics: CAC, LTV and payback
Whether one more customer makes money, how long until cash comes back, and why the LTV formula lies if you treat it as truth.