Most SaaS companies know their revenue and can estimate gross margin, but few can answer what it costs to serve a specific customer. Here’s why cost-to-serve is where margin erosion begins, and what high-performing SaaS operators do to measure and manage it.
Most SaaS and AI companies know their revenue growth rate within minutes of asking. Far fewer can give an equally confident answer about what it actually costs to deliver their product to a specific customer, support a given implementation, or operate an AI-driven feature at scale. That gap matters more than most finance teams acknowledge.
Cost of Goods Sold (COGS) is the accounting category that captures those delivery costs. In traditional manufacturing, the definition is relatively clear: raw materials, direct labor, and production overhead. In SaaS and AI businesses, the lines are less obvious. Infrastructure is distributed across cloud providers. Support costs are shared across accounts. AI inference expenses scale with usage patterns that pricing teams didn’t anticipate. Vendor contracts grow quietly in the background. When companies draw COGS boundaries too narrowly, they overstate gross margins. When they draw them too broadly, they obscure operating efficiency. Either way, the result is cost data that finance leaders can’t confidently use to make pricing, allocation, or investment decisions.
Getting COGS right is not primarily an accounting exercise. It is a precondition for gross margin quality, pricing accuracy, customer-level profitability analysis, and vendor accountability. For SaaS and AI companies operating at any meaningful scale, it deserves the same rigor that finance teams apply to ARR and churn.
What COGS Means in a SaaS or AI Company
The clearest test for what belongs in COGS is also the simplest: does this cost exist because a customer is using the product? If removing a customer from the platform would eliminate or meaningfully reduce this cost, it belongs in COGS. If the cost would persist regardless of how many customers you have, it belongs below the gross margin line.
In SaaS and AI businesses, that test applies to a broader set of costs than most companies initially classify. Cloud infrastructure clearly qualifies. So does AI inference spend. So do support and customer success costs directly tied to product delivery and retention. The challenge is that many of these costs are shared across the entire customer base, which means they require allocation rather than direct assignment. That allocation step is where much of the precision lives, and much of the difficulty.
The Core COGS Categories
Cloud infrastructure and hosting typically represent the largest COGS component for most SaaS businesses. Compute, storage, data processing, CDN usage, and monitoring tools that run in production all scale with customer activity. High-volume accounts, data-intensive workloads, and feature-heavy plans consume meaningfully more infrastructure than lighter users, even when their contract value looks similar on paper.
AI inference and compute costs have introduced a new layer of COGS complexity. Inference requests, token usage, embedding generation, fine-tuning workloads, GPU compute, and vector database costs are consumption-based by nature. They don’t scale linearly with seat count or ARR. Bessemer Venture Partners’ State of AI 2025 report highlights that many AI-native companies operate with lower gross margins than traditional SaaS businesses, largely because inference, compute, and usage-based infrastructure costs scale directly with customer activity. For any software company that has embedded AI capabilities into its product, those costs need active classification, allocation, and governance, not just periodic review.
Third-party vendor and API costs form another significant and often undertracked COGS category. Payment processors, messaging APIs, data enrichment providers, security vendors, and specialized data platforms all contribute to product delivery. These vendor relationships frequently begin small and grow as usage scales, often with contract terms (including CPI escalators and renewal price increases) that compound costs over time. The question is rarely whether vendor spend belongs in COGS; it usually does. The question is whether finance has the visibility to track it and the governance to manage it.
Customer support belongs in COGS to the extent it is tied to product delivery and ongoing usage. Support teams handling technical escalations, product questions, and incident resolution are not a sales or marketing function. Their cost is a cost of serving customers. The same logic extends to customer success work genuinely tied to retention, onboarding, and product adoption, as opposed to growth-oriented account management.
Implementation and professional services deserve specific attention. Data migrations, custom integrations, onboarding programs, and project-based delivery work are often absorbed as overhead or treated as separately priced services. Either way, they generate real delivery costs. Companies that consistently underestimate implementation complexity in their COGS tend to discover the margin impact only once the pattern has repeated across enough accounts to move the aggregate number.
What Typically Stays Out of COGS
Not every operating expense belongs in COGS, and conflating delivery costs with operating overhead creates its own distortions. Costs that generally sit below the gross margin line include executive salaries, finance and legal functions, general HR, corporate marketing, office rent, recruiting, and administrative software not directly supporting product delivery.
The principle is the same in reverse: if this cost would exist at roughly the same level even if you had no customers, it belongs in operating expenses, not in COGS.
Where Classification Gets Complicated
Several cost categories consistently create gray areas in SaaS and AI COGS treatment. AI engineering infrastructure is one of the most contested. Teams building and maintaining model pipelines, LLM fine-tuning workflows, and inference architecture sit at the boundary between R&D and delivery. The right classification depends on whether the work is customer-facing and ongoing (COGS) or exploratory and capability-building (R&D). Companies that apply a single blanket treatment to all AI engineering often end up with neither an accurate COGS figure nor a useful R&D number.
Dedicated customer AI models, custom integrations, and customer-specific engineering work present a similar challenge. When engineering resources are consumed maintaining a single customer’s unique configuration, those costs belong in that customer’s COGS. Absent that level of tracking, they disappear into general engineering overhead, making the account appear more profitable than it actually is.
Customer success is another common gray area. CS that is operationally tied to onboarding, adoption, and retention belongs in COGS. CS primarily oriented toward expansion and upsell is better classified as a sales and marketing cost. Many companies blend these functions without distinguishing between them in cost reporting, which distorts both gross margin and the sales efficiency metrics below it.
Why COGS Visibility Matters for Margin Quality
The practical consequence of poor COGS classification is that gross margin becomes unreliable as a management signal. A blended gross margin of 78 percent may look healthy relative to industry benchmarks (Benchmarkit’s 2025 B2B SaaS Performance Metrics report puts median total gross margin for B2B SaaS companies near 77 percent), but it says nothing about which customers, products, or segments are contributing to that number and which are eroding it.
For companies that have added AI features, the problem is increasingly acute. The High Alpha and OpenView 2025 SaaS Benchmarks Report found gross margins compressing meaningfully year-over-year for many early-stage companies, with compute and AI-related costs frequently cited as a primary driver. When inference costs aren’t properly classified and allocated, AI features appear as pure upside on a revenue dashboard while quietly compressing the margins underneath them.
This dynamic is covered in depth in our article on why SaaS margins are shrinking even as revenue grows.
Vendor Management as Margin Discipline
Vendor spend is one of the fastest-growing components of SaaS and AI COGS, and one of the least governed. Modern software products depend on a stack of third-party providers whose contracts often include usage-based pricing, annual renewal increases, and CPI escalators that compound over time. When no one owns that visibility centrally, costs grow without accountability.
Effective vendor management in a COGS context is not an administrative function. It is a margin discipline. Finance teams that understand which vendors affect COGS, which customers consume the most vendor resources, and which contracts contain upcoming price changes can make proactive decisions about renewals, pricing adjustments, and contract consolidation. Teams that lack that visibility tend to discover vendor cost growth after the margin impact has already accumulated. For AI companies managing multiple LLM providers, vector database vendors, and inference infrastructure, that visibility is especially critical given how quickly usage scales.
Connecting COGS to Customer and Product Profitability
Accurate COGS classification is a foundation, not a destination. The strategic value of getting COGS right is that it enables the next level of analysis: understanding profitability at the customer level, the product level, and the segment level. A company that can see gross margin by customer cohort, pricing tier, and product line can make pricing decisions grounded in actual cost structure, identify accounts where cost-to-serve has grown beyond what revenue justifies, and target renewals where margin improvement is genuinely available. A company relying on blended averages makes those same decisions without that signal.
For a detailed framework on distributing shared COGS across customers, products, and business units, our article on how to allocate costs across customers and products in software companies covers the allocation methodology in full.
Where Cogs’z Fits
Cogs’z helps finance, sales, and customer success teams connect revenue, usage, vendor spend, and cost allocation data so they can see how COGS affects profitability by customer, product, and segment. Rather than managing COGS as a set of disconnected line items, Cogs’z makes it possible to track which costs belong to which accounts, how vendor contracts affect delivery margins, and where profitability is strongest and weakest across the business.
The Bottom Line
COGS in SaaS and AI is harder to define than in traditional businesses, but that complexity is not a reason for imprecision. The costs of delivering a software product (infrastructure, AI inference, vendor APIs, customer support, implementation) are real, they scale with usage, and they need to be classified and allocated accurately for gross margin to function as a useful metric.
Companies that get this right gain a clearer picture of which customers and products are genuinely profitable, which are priced correctly relative to their delivery cost, and where vendor and AI spend needs governance before it compounds into a margin problem. For CFOs and finance leaders building that visibility, COGS classification is where the work starts.
Brad Perry is the CEO of Cogs’z, a profitability management platform built for B2B SaaS companies. Brad co-founded DealerSocket, an end-to-end platform in the automotive industry, where he experienced firsthand the margin challenges that Cogs’z is designed to solve. Cogs’z automates customer-level cost allocation so finance, CS, and sales teams share a single, accurate, view of who’s profitable and why. Learn more or request a demo at cogsz.com.
References
- Bessemer Venture Partners — State of AI 2025
- Benchmarkit — 2025 B2B SaaS Performance Metrics
- High Alpha and OpenView — 2025 SaaS Benchmarks Report