Skip to content
← Blog

AI Development Costs Hit 10x: The Cost Control Framework JetBrains Built (And You Can Steal)

Learn how to implement AI development cost control before your spend spirals. JetBrains saw costs 10x in 6 months, here's the framework to prevent it.

9 min readSimon-Daniel März
AI Development Costs Hit 10x: The Cost Control Framework JetBrains Built (And You Can Steal)Generated with the help of AI

JetBrains watched their AI development expenses jump roughly 10x in six months. Not because a single project went off the rails. Not because of a billing error. But because their own developers, the people building AI-powered tools, were choosing which models, APIs, and workflows to use independently, with no centralized visibility into what it all cost.

If your company is deploying AI features, integrating LLM APIs, or running internal AI assistants, this should sound familiar. The pattern is the same almost everywhere: developers adopt AI tools fast, usage compounds quietly, and by the time finance flags the invoice, you're looking at a line item that rivals your entire infrastructure budget.

This article breaks down exactly why AI costs spiral and gives you a four-step framework for ai development cost control, with a concrete code example, real numbers, and best practices you can apply this quarter.

Why AI Costs Don't Grow Linearly, They Compound

The core problem isn't that AI is expensive per call. A single GPT-4o prompt might cost $0.003, $0.01. That's trivial. The problem is volume, frequency, and architectural choices that multiply costs in ways most teams don't anticipate.

Here's a realistic scenario. A mid-sized SaaS company adds an AI-powered feature to summarize customer support tickets:

  • Month 1: 5 developers testing the feature, ~2,000 API calls/day → ~$60/day → ~$1,800/month
  • Month 3: Feature ships to 10% of users, calls jump to 15,000/day → ~$450/day → ~$13,500/month
  • Month 6: Full rollout + developers added RAG retrieval, multi-turn conversations, and a second model for classification → 80,000 calls/day with an average cost of $0.012/call → ~$960/day → ~$28,800/month

That's a 16x increase in six months, and it tracks JetBrains' experience almost exactly. The cost didn't explode because anyone made a mistake. It exploded because:

  1. No per-feature cost tracking. The company tracked total API spend, not which features or teams drove it.
  2. Model selection by habit, not economics. Developers default to the most capable (and expensive) model for every task, even when a cheaper one suffices 95% of the time.
  3. Prompt bloat. System prompts grow from 200 tokens to 2,000 tokens over time. Context windows fill up. Nobody audits token counts.
  4. Retry storms. Failed calls retry aggressively, sometimes 5x, multiplying costs without adding value.

Step 1: Build a Cost-Visibility Layer Around Every AI Call

You cannot control what you cannot see. The single most impactful action is wrapping every LLM API call with instrumentation that tracks who made the call, which model was used, how many tokens were consumed, and what it cost.

Here's a concrete TypeScript middleware that wraps OpenAI API calls and logs cost data per request. You can adapt this pattern to any LLM provider:

import OpenAI from "openai";

// Pricing per 1M tokens (input/output) as of mid-2026
const MODEL_PRICING: Record<string, { input: number; output: number }> = {
  "gpt-4o":       { input: 2.50,  output: 10.00 },
  "gpt-4o-mini":  { input: 0.15,  output: 0.60  },
  "gpt-4.1":      { input: 2.00,  output: 8.00  },
  "gpt-4.1-mini": { input: 0.40,  output: 1.60  },
};

interface CallMetadata {
  feature: string;     // e.g. "ticket-summary", "code-review"
  userId?: string;
  teamId?: string;
}

interface CostResult {
  model: string;
  inputTokens: number;
  outputTokens: number;
  costUsd: number;
  feature: string;
  userId?: string;
  teamId?: string;
}

function calculateCost(
  model: string,
  inputTokens: number,
  outputTokens: number
): number {
  const pricing = MODEL_PRICING[model];
  if (!pricing) return 0;
  return (
    (inputTokens / 1_000_000) * pricing.input +
    (outputTokens / 1_000_000) * pricing.output
  );
}

async function trackedChatCompletion(
  client: OpenAI,
  params: OpenAI.ChatCompletionCreateParamsNonStreaming,
  meta: CallMetadata
): Promise<{ response: OpenAI.ChatCompletion; cost: CostResult }> {
  const response = await client.chat.completions.create(params);
  const usage = response.usage;

  const cost: CostResult = {
    model: params.model,
    inputTokens: usage?.prompt_tokens ?? 0,
    outputTokens: usage?.completion_tokens ?? 0,
    costUsd: calculateCost(
      params.model,
      usage?.prompt_tokens ?? 0,
      usage?.completion_tokens ?? 0
    ),
    feature: meta.feature,
    userId: meta.userId,
    teamId: meta.teamId,
  };

  // Send to your analytics pipeline (e.g. PostHog, Datadog, BigQuery)
  await logCostEvent(cost);

  return { response, cost };
}

async function logCostEvent(cost: CostResult): Promise<void> {
  // Replace with your actual analytics sink
  console.log(
    `[AI-COST] feature=${cost.feature} model=${cost.model} ` +
    `input=${cost.inputTokens} output=${cost.outputTokens} ` +
    `cost=$${cost.costUsd.toFixed(4)}`
  );
}

// Usage:
const openai = new OpenAI();
const { response, cost } = await trackedChatCompletion(
  openai,
  {
    model: "gpt-4o",
    messages: [
      { role: "system", content: "Summarize this support ticket in 3 sentences." },
      { role: "user", content: ticketBody },
    ],
  },
  { feature: "ticket-summary", userId: "u_12345", teamId: "support-eu" }
);

console.log(`This call cost $${cost.costUsd.toFixed(4)}`);

This gives you per-call, per-feature cost attribution. Run it for two weeks and you'll have answers to questions like:

  • Which feature accounts for 70% of the spend? (It's usually 1-2 features.)
  • Which team's average cost-per-call is 3x the company average? (Usually means they're using a larger model than needed.)
  • What's the token distribution? If your median call uses 150 output tokens but your P95 uses 3,800, you have outlier prompts that need investigation.

JetBrains found that most of their cost concentration came from a small number of high-volume internal workflows, not from broad developer experimentation. That's the pattern most companies see. Visibility lets you find the expensive outliers fast.

Step 2: Set Per-Feature Budgets, Not Just a Global Cap

A global monthly cap on your OpenAI or Anthropic spend is a blunt instrument. It either fires too late (you discover the overspend at month-end) or too early (it kills legitimate usage during a busy period).

Effective ai development cost control requires budgets at the feature or team level:

Budget TierExamplePurpose
Per-call limitMax 4,096 output tokens per requestPrevent runaway generation
Per-feature daily cap"ticket-summary" feature: $50/dayCatch runaway loops fast
Per-team monthly budgetTeam "Support-AI": $3,000/monthDepartmental accountability
Global monthly ceilingOrg-wide: $25,000/monthSafety net

The per-call token limit is the cheapest to implement and prevents the most common waste: a prompt that accidentally triggers a 10,000-token response when you only need 200 tokens. Always set max_tokens explicitly.

The per-feature daily cap is where most of the savings come from. In your cost-tracking middleware, add a simple check before making the call:

const DAILY_BUDGETS: Record<string, number> = {
  "ticket-summary": 50.0,   // $50/day
  "code-review": 30.0,      // $30/day
  "chat-assistant": 100.0,  // $100/day
};

async function checkBudget(feature: string): Promise<boolean> {
  const todaySpend = await getTodaysSpend(feature); // from your analytics DB
  const limit = DAILY_BUDGETS[feature] ?? Infinity;
  if (todaySpend >= limit) {
    console.warn(`[AI-BUDGET] ${feature} exceeded daily limit ($${limit}). Skipping.`);
    return false;
  }
  return true;
}

When a feature hits its daily cap, you can either degrade gracefully (use a cheaper model, return a cached response, or show a "try again tomorrow" message) rather than shutting it off entirely.

SAP's approach to tiered AI cost management, which we covered in detail in our analysis of enterprise AI token costs and SAP's three-tier model, uses a similar principle: classify your AI workloads by criticality, then assign different models and limits to each tier.

Step 3: Optimize the Expensive 80%

Once you have visibility, you'll typically find that 20% of your AI features drive 80% of the cost. Here are the four optimization techniques that deliver the biggest savings, ranked by impact:

3a. Model Right-Sizing

This is the single biggest lever. Most teams default to the most powerful model for every task. In practice:

  • Sentiment analysis, classification, extraction: A fine-tuned small model or gpt-4.1-mini handles this at 1/10th the cost of gpt-4o.
  • Summarization of structured data: Often achievable with gpt-4.1-mini, no one reading a support ticket summary notices the difference.
  • Complex reasoning, code generation, multi-step planning: This is where the expensive models genuinely earn their price.

Run an A/B comparison on your top 5 features. For each one, measure quality (human eval or automated rubric) on the expensive model vs. a cheaper alternative. If quality drops less than 5% but cost drops 80%, the switch is a no-brainer.

Real numbers: Switching a ticket-summarization feature from gpt-4o ($2.50/$10.00 per 1M tokens) to gpt-4.1-mini ($0.40/$1.60) cuts the per-call cost from ~$0.008 to ~$0.001, an 87% reduction on a feature that might run 50,000 times/day.

3b. Prompt Compression

Every unnecessary token in your system prompt costs money on every single call. Audit your prompts quarterly. Common waste includes:

  • Duplicate instructions: "Be concise. Keep your answer short. Do not elaborate unnecessarily." (Three sentences saying the same thing.)
  • Overly generic context: Including your full company wiki in a RAG prompt when only 3 documents are relevant.
  • Verbose few-shot examples: Five examples when two would suffice.

Practical tip: Log the system prompt token count alongside cost. If you see it climbing from 400 to 1,200 tokens over several sprints, that's a 3x cost increase on your system prompt alone, paid on every single call.

We covered prompt compression and caching strategies in depth in our guide to slashing production RAG costs by 80%, the TL;DR is that caching your system prompt prefix with OpenAI's prompt caching can cut input token costs by 50-90% on repeated patterns.

3c. Response Caching

If your users ask the same questions or your system processes similar inputs, cache responses. A simple hash-based cache keyed on (model, system_prompt_hash, user_message_hash) can eliminate 30-60% of calls for features like FAQ bots or document summarization.

Cache invalidation is straightforward: set a TTL (e.g., 24 hours for content summaries, 1 hour for real-time data) and invalidate on source-document changes.

3d. Batch Processing

Not every AI call needs to be real-time. If you're summarizing 10,000 support tickets for a weekly report, use OpenAI's Batch API, it runs at 50% of the standard price and completes within 24 hours. For analytics, trend detection, and periodic reporting, batching is essentially free money.

Step 4: Alerts That Fire Before the Damage

Budgets are useless if you only check them monthly. Set up real-time alerts at meaningful thresholds:

  • Feature-level spike: Alert if any single feature's hourly cost exceeds 2x its trailing 7-day average. This catches runaway loops and prompt regressions immediately.
  • Model-level anomaly: Alert if a team starts routing traffic to a more expensive model than their historical baseline (e.g., switching from gpt-4.1-mini to gpt-4o without a corresponding quality justification).
  • Monthly trend: Alert at 60% and 80% of monthly budget. This gives you time to act, investigate, optimize, or adjust the budget, rather than discovering the overshoot on the invoice.

Wire these into Slack, Microsoft Teams, or your incident-management tool. A cost alert should be treated with the same urgency as a latency spike or error-rate increase.

Best Practices for Long-Term AI Cost Control

Here are five practices that compound over time:

  1. Assign cost ownership. Every AI feature should have an owner (person or team) who is accountable for its cost trajectory. When nobody owns it, costs grow unchecked.

  2. Include cost in your AI feature checklist. Before shipping any feature that calls an LLM, require answers to: What model? What's the expected call volume? What's the estimated monthly cost? What's the cheaper fallback if the model is unavailable or over-budget?

  3. Review AI spend in sprint retrospectives. Add a 5-minute "AI cost review" to your bi-weekly retro. Show the trend. Celebrate reductions. Flag increases. Normalizing cost awareness is 80% of the battle.

  4. Maintain a model-pricing spreadsheet (or automate it). Model pricing changes frequently. What was cost-effective six months ago may not be today. Track pricing changes and re-evaluate your model assignments quarterly.

  5. Build a cost-aware development culture. JetBrains' core insight was that developers were making independent choices about AI tooling, which is great for velocity but terrible for cost governance. The solution isn't to restrict choice. It's to make cost data visible to developers so they self-optimize. A simple dashboard showing "your feature cost $X last week" changes behavior faster than any top-down policy.

These principles align closely with what we've observed across multiple AI integration projects, the teams that control AI spend best are the ones that treat it like any other infrastructure cost: visible, owned, and reviewed regularly. Companies that would rather not build cost-tracking and optimization infrastructure in-house often bring in a specialized AI solutions partner to set up the tooling and governance framework once, then run it themselves.

The Bottom Line

JetBrains' 10x cost explosion isn't an outlier, it's the default trajectory for any company that adopts AI without cost controls. The fix isn't complicated, but it requires deliberate action:

  1. Instrument every AI call with feature-level cost attribution (one afternoon of work).
  2. Set per-feature budgets with graceful degradation instead of a single global cap.
  3. Optimize the top 20% of features driving 80% of spend, model right-sizing alone can cut costs 50-80%.
  4. Alert on anomalies in real time, not monthly.

The cost of doing nothing is predictable: your AI line item doubles every quarter until someone in finance forces a blanket shutdown that kills both the expensive experiments and the valuable production features. Better to build the guardrails now while the numbers are still manageable.

Want to see what AI cost optimization looks like for your specific stack? Explore our AI solutions approach, or start by instrumenting your top three AI features with the middleware pattern above this week. The data will tell you exactly where to focus.


Source: Our First Moves to Get AI Spend Under Control

Continue in this topic

AI and automation