# LLM API vs Self-Hosted Cost Calculator

> Source: https://netray.co/tools/llm-api-vs-self-hosted-cost-calculator
> Publisher: Netray (netray.co), AI and integration engineering for ERP and manufacturing systems.
> Section: Free Tools

## Short answer

Model your API bill from requests and token mix, compare it against an all-in self-hosted monthly cost, and see monthly and annual savings.

## Category

on-prem-ai

## Tool

**Kind:** calculator

**Inputs:**

#### Requests per day

**Key:** daily_requests

**Type:** number

**Default:** 25000

**Min:** 100

**Max:** 1000000

**Step:** 100

**Unit:** req/day

**Help:** All LLM calls per day, including automated and agentic requests.

#### Average input tokens per request

**Key:** avg_input_tokens

**Type:** number

**Default:** 1500

**Min:** 100

**Max:** 100000

**Step:** 100

**Unit:** tokens

**Help:** Prompt plus context; RAG requests commonly run 1,000-4,000 input tokens.

#### Average output tokens per request

**Key:** avg_output_tokens

**Type:** number

**Default:** 400

**Min:** 50

**Max:** 8000

**Step:** 50

**Unit:** tokens

**Help:** Generated tokens per response; chat averages 300-700.

#### API input price

**Key:** api_input_price

**Type:** number

**Default:** 3

**Min:** 0.1

**Max:** 20

**Step:** 0.1

**Unit:** $/M tokens

**Help:** Per-million input token price from your provider's rate card.

#### API output price

**Key:** api_output_price

**Type:** number

**Default:** 15

**Min:** 0.4

**Max:** 80

**Step:** 0.1

**Unit:** $/M tokens

**Help:** Per-million output token price; typically 3-5x the input price.

#### Self-hosted all-in monthly cost

**Key:** self_hosted_monthly_cost

**Type:** number

**Default:** 5500

**Min:** 1000

**Max:** 100000

**Step:** 500

**Unit:** $/mo

**Help:** Amortized hardware plus power, support, and ops share. Use our TCO calculator to derive this.

**Outputs:**

#### Monthly API cost

**Key:** monthly_api_cost

**Expr:** round(daily_requests * 30 * (avg_input_tokens * api_input_price + avg_output_tokens * api_output_price) / 1000000)

**Format:** currency

**Description:** Requests times per-request token cost across a 30-day month.

#### Monthly savings self-hosting

**Key:** monthly_savings

**Expr:** monthly_api_cost - self_hosted_monthly_cost

**Format:** currency

**Description:** Negative means the API is cheaper at this volume.

**Primary:** true

#### Annual savings self-hosting

**Key:** annual_savings

**Expr:** monthly_savings * 12

**Format:** currency

**Description:** Monthly savings projected across 12 months at constant volume.

**Primary:** true

#### API cost per 1,000 requests

**Key:** api_cost_per_1k_requests

**Expr:** round(monthly_api_cost / (daily_requests * 30 / 1000) * 100) / 100

**Format:** currency

**Description:** A unit economics figure useful for per-feature budgeting.

**Disclaimer:** Estimates only. API rate cards, caching discounts, and batch pricing change frequently; self-hosted quality parity depends on model choice. Validate with a measured pilot.

## Content

**Intro:** This calculator finds the crossover point where self-hosting a large language model becomes cheaper than paying per-token API prices, built for engineering leaders whose LLM API invoices are growing month over month. It models your bill bottom-up from daily requests and the input/output token mix - the split matters because output tokens typically cost 3-5x more - then compares it against an all-in self-hosted monthly cost. The result is a clean monthly and annual savings figure plus per-1,000-request unit economics you can use in feature-level budgeting.

**Sections:**

#### How the math works

**Body:** Your per-request cost is input tokens times the input rate plus output tokens times the output rate, divided by one million. At the defaults - 1,500 input and 400 output tokens against a $3/$15 rate card - each request costs about one cent, and 25,000 daily requests compound to roughly $7,900 per month. The self-hosted side is a single all-in number you supply: amortized hardware, power, support, and an operations staffing share. We keep it as one input deliberately, because the honest all-in figure is the one self-hosting advocates most often understate - use our On-Prem LLM TCO Calculator to derive it rigorously rather than guessing.

#### Reading the crossover correctly

**Body:** The comparison assumes the self-hosted model delivers acceptable quality for your workload, which is a real question, not a footnote. In practice the pattern by workload type is consistent across Netray engagements.

**Bullets:**

- Classification, extraction, and RAG answering: 8B-32B open models match frontier APIs; self-hosting wins early
- Code generation and complex reasoning: parity needs 70B-class models, raising self-hosted cost
- Agentic workloads firing thousands of automated calls: token volume explodes; self-hosting wins decisively
- Low-volume, high-stakes tasks: stay on APIs; hardware would idle

#### What to do with your result

**Body:** If monthly savings are strongly positive, the next step is not a purchase order - it is a quality pilot proving an open-weight model handles your top request types, since cost savings at degraded quality are savings nobody will accept. If the number is near zero, watch your request growth rate: API bills scale linearly while self-hosted cost is a step function, so a workload growing 15% monthly crosses over within two quarters. If savings are negative, self-hosting still may be justified by data sovereignty, latency, or compliance - just fund it as a risk decision, not a cost decision.

#### How Netray helps you capture the savings

**Body:** Netray runs the migration end to end: we benchmark open-weight candidates against your real prompt logs, size and deploy the serving infrastructure, and implement routing so high-stakes requests can still reach a frontier API while the bulk of traffic runs on your hardware. That hybrid pattern typically captures 70-90% of the modeled savings at zero perceived quality loss. Engagements start with a two-week evaluation using your actual traffic sample, so the business case is measured rather than modeled.

**Cta:** Calculate your savings, then let Netray benchmark an open-weight model against your real traffic before you commit.

**Faq:**

#### Why do input and output tokens need separate prices?

**Answer:** Because providers charge asymmetrically - generating tokens costs more compute than reading them, and rate cards reflect that with output prices typically 3-5x input. Workload shape therefore changes your bill dramatically: a RAG pipeline stuffing 4,000 context tokens per request is input-dominated, while a report generator is output-dominated. Modeling the mix explicitly keeps the comparison honest instead of relying on a blended average that may not match your traffic.

#### What should I include in the self-hosted monthly cost?

**Answer:** Everything: hardware capex amortized over three years (with a 25-30% uplift over GPU list price for the server platform), power and cooling, vendor support contracts, and a realistic share of an engineer's time - typically 0.3-0.7 FTE for a small production cluster. The most common analysis error is entering only amortized GPU cost, which understates the true figure by 40-60% and produces a crossover that operations reality will not honor.

#### Do prompt caching and batch API discounts change the conclusion?

**Answer:** They can shift the crossover meaningfully, so model them. Prompt caching cuts input costs 50-90% for workloads reusing large fixed contexts, and batch endpoints often discount 50% for latency-tolerant jobs. Apply those discounts to your effective rates in this calculator to see the adjusted picture. Note that self-hosted stacks get equivalent tricks - prefix caching in vLLM is free - so the discounts partially cancel rather than settling the question.

## Search terms

llm api cost calculator, self-hosted llm vs api pricing, openai api cost vs self hosting, token pricing calculator enterprise, llm cost per request, when to self host llm

---
Talk to an engineer: https://netray.co/contact?intent=erp_ai | Machine catalog: https://netray.co/agent/catalog.json
