AI Guides · 12 min read

How to Reduce AI API Costs: A Practical Developer Checklist

Learn how to reduce AI API costs: meter tokens, route to smaller models, cap outputs, trim history, and use prompt caching, batch APIs, and quota alerts.

Illustration of teal, gold, and coral token stacks flowing through a funnel into a smaller path beside a compact cube

To reduce AI API costs, meter every token bucket, route routine work to smaller models, cap output and reasoning tokens, trim stale conversation history, reuse stable prefixes with prompt caching, move asynchronous workloads to batch APIs, and configure spend alerts alongside hard limits so runaway loops never turn into surprise invoices.

Unlike consumer chat subscriptions for ChatGPT, Claude, or Gemini, developer APIs bill per token processed—and sometimes per tool call. A lower headline price per million tokens does not guarantee a lower bill: tokenizers segment text differently across providers, and hidden reasoning tokens can easily outnumber the visible reply.

How Are AI API Bills Actually Metered?

Before changing prompts or switching models, look at the usage object returned by every API response. Modern AI APIs split token billing into four distinct buckets:

  1. Uncached input (base input): New prompt tokens processed at the model’s standard input rate.
  2. Cached input (cache reads or hits): Reused prompt-prefix tokens billed at a discounted rate—often 5% to 10% of base input, or up to 95% less than standard input in OpenAI’s pricing structure.
  3. Cache writes: Creating a reusable cache entry can cost more than standard input. As of 2026-11-08, OpenAI charges 1.25× base input for a 30-minute cache write and 2.5× for a 12-hour write; Anthropic charges 1.25× for a 5-minute write and 2× for a 1-hour write. Cache-write pricing is a replacement rate for those tokens, not an extra fee stacked on top of base input.
  4. Output, including reasoning or thinking tokens: Every generated token is billed at the output rate. As documented in the OpenAI Help Center guide on counting tokens, reasoning tokens are not visible as answer text, but they count toward output usage and are billed as output tokens. Google’s Gemini 4 Argon pricing likewise bills output including thinking tokens, and Anthropic’s adaptive and extended thinking tokens are billed at the model’s standard output rate.

If you are new to how providers segment text before billing, read our explainer on what a token is in AI.

How Do Official AI API Prices Compare in 2026?

The table below shows official standard, real-time list prices in USD per 1 million tokens, checked 2026-11-08 against the OpenAI API pricing page, Anthropic Claude pricing documentation, and Google Gemini Developer API pricing page (as well as Google’s Gemini 4 Argon launch announcement).

Model Uncached Input Cached Input (Read) Output (Includes Thinking) Key Billing Notes (Checked 2026-11-08)
GPT-6 Astra $10.00 $1.00 $50.00 Short context (≤272K input). Cache write: 30m $12.50 / 12h $25.00
GPT-6.1 Sol $2.00 $0.10 $10.00 Short context (≤272K input). Cache write: 30m $2.50 / 12h $5.00
GPT-6 Sol $2.00 $0.20 $10.00 Same I/O as 6.1 Sol, but 2× higher cache-read rate
GPT-6.1 Terra $1.00 $0.05 $5.00 Short context (≤272K input). Cache write: 30m $1.25 / 12h $2.50
GPT-6 Luna $0.10 $0.01 $0.50 Short context (≤272K input). Cache write: 30m $0.125 / 12h $0.25
Claude Opus 5.5 $4.00 $0.20 $20.00 Cache write: 5m $5.00 / 1h $8.00
Claude Sonnet 5.5 $2.00 $0.10 $10.00 Cache write: 5m $2.50 / 1h $4.00
Claude Haiku 5.5 (≤100K) $0.10 $0.01 $0.50 Prompts ≤100K tokens. Cache write: 5m $0.125 / 1h $0.20
Claude Haiku 5.5 (>100K) $0.50 $0.05 $2.50 Prompts >100K tokens. Cache write: 5m $0.625 / 1h $1.00
Gemini 4 Argon (through Nov 30, 2026) $2.00 $0.10 $10.00 Introductory pricing. Implicit caching only; no free tier
Gemini 4 Argon (starting Dec 1, 2026) $4.00 $0.20 $20.00 Standard rates double on Dec 1, 2026 after intro window ends

Watch out for context-length cliff surcharges and mode multipliers (checked 2026-11-08):

  • OpenAI long-context surcharge: Prompts exceeding 272K input tokens pay 2× the standard input and cache rates and 1.5× the output rate across the entire request (for example, GPT-6.1 Sol jumps to $4.00 input and $15.00 output; GPT-6 Astra jumps to $20.00 input and $75.00 output).
  • Priority and regional multipliers: OpenAI Fast mode costs 2× standard rates, while Anthropic’s Fast mode on Claude Opus 5.5 costs $8.00 input and $40.00 output. Data-residency or regional routing can also add a 10% (1.1×) surcharge on applicable models.

To see how list prices translate to a single call, take a worked illustration holding token counts constant at 25,000 uncached input tokens and 5,000 output tokens on the standard real-time tier:

  • GPT-6 Astra: $0.50
  • Claude Opus 5.5: $0.20
  • Gemini 4 Argon (from Dec 1, 2026): $0.20
  • GPT-6.1 Sol, Claude Sonnet 5.5, or Gemini 4 Argon (through Nov 30, 2026): $0.10 each
  • GPT-6.1 Terra: $0.05
  • GPT-6 Luna or Claude Haiku 5.5 (≤100K): $0.005 each

In production, identical text will not produce identical token counts across vendors, and reasoning models may generate thousands of internal thinking tokens. For a wider breakdown of model tiers and task examples, see our AI API pricing comparison.

7-Point Developer Checklist to Cut AI API Spend

Use the seven tactics below in order. Each includes where it saves money and where it backfires.

1. Meter Input, Cache Reads, Cache Writes, and Reasoning Output

What to do: Log the raw usage payload on every response. On OpenAI, record input_tokens_details.cached_tokens, cache_write_tokens, and output_tokens_details.reasoning_tokens. On Anthropic, record input_tokens (which counts only tokens after the last cache breakpoint), cache_creation_input_tokens, and cache_read_input_tokens. Compute request cost using:

cost = (ordinary_input × input_price + cached_reads × cache_price + cache_writes × write_price + total_output × output_price) / 1,000,000

Aggregate that number into cost per successful task, not just cost per million tokens.

  • When it works: Every production workload. Itemized telemetry immediately exposes when silent reasoning tokens or uncached long-context requests dominate your bill.
  • When it fails: Dashboards that only graph “total tokens” hide whether input tokens were discounted cache reads or 1.25×–2.5× cache writes. Also note that on OpenAI, cached input tokens still count toward your tokens-per-minute (TPM) rate limits even when billed at a discount.

2. Choose a Smaller Model and Route Hard Tasks Upward

What to do: Default each endpoint to the smallest model that passes your evaluation suite, and route only low-confidence outputs, complex multi-step tool chains, or failed validations to a flagship tier. OpenAI’s documentation pairs GPT-6 Luna ($0.10/$0.50) with high-volume work, GPT-6.1 Sol ($2.00/$10.00) with balanced intelligence and cost, and GPT-6 Astra ($10.00/$50.00) with the hardest reasoning tasks. Anthropic positions Claude Haiku 5.5 ($0.10/$0.50 up to 100K input) for classification, extraction, and routing, Sonnet 5.5 ($2.00/$10.00) for everyday coding and agents, and Opus 5.5 ($4.00/$20.00) for long-horizon agentic coding.

  • When it works: Classification, structured extraction, routing, moderation, and high-volume support replies governed by a clear rubric.
  • When it fails: Downgrading a difficult coding or agentic workflow to a tiny model can increase total cost per successful task if the cheaper model loops, hallucinates tool arguments, or triggers repeated retries. Also watch calendar-based pricing shifts: routing workloads to Gemini 4 Argon costs $2.00 input / $10.00 output through November 30, 2026, but doubles to $4.00 / $20.00 on December 1, 2026.

3. Cap Output Tokens and Reasoning Effort

What to do: Set explicit ceilings on generation and dial back thinking depth when deep chain-of-thought is unnecessary.

  • In the OpenAI Responses API, set max_output_tokens. In Chat Completions, use max_completion_tokens (which caps both visible output and reasoning tokens; the legacy max_tokens parameter is deprecated). Lower reasoning.effort (including none where supported, such as batch classification) for straightforward prompts.

  • In the Anthropic Messages API, max_tokens is required on every call, and the effort parameter lets you tune thinking budget.

  • In the Gemini API, configure thinking levels (low, medium, or high) to match task complexity, and request concise structured outputs (such as JSON schemas) instead of prose explanations.

  • When it works: Extraction, taggers, tool-call generation, and endpoints where unbounded thinking tokens inflate output charges at 5× the input price.

  • When it fails: Setting max_output_tokens or max_tokens too low truncates JSON payloads or cuts off a model mid-thought before it emits any visible answer—charging you for the reasoning tokens while yielding a failed request. Similarly, forcing low effort on genuinely hard math or architecture problems causes retries that erase the per-call savings.

4. Trim Conversation History and Prevent Context Rot

What to do: Stop appending every full tool response, stack trace, and outdated turn indefinitely. Summarize older turns, drop redundant DOM dumps or file reads after extraction, and keep only the state required for the next step. For a deep dive into managing multi-turn state on Claude, read our guide to Claude API message threads.

  • When it works: Long-running coding assistants, customer-support threads, and multi-step agents. Trimming history prevents context rot—where irrelevant middle context degrades accuracy—and keeps prompts safely below OpenAI’s 272K long-context surcharge (2× input, 1.5× output) and Claude Haiku 5.5’s >100K tier jump (5× higher input and output rates).
  • When it fails: Over-aggressive pruning can strip away user constraints the model still needs. Just as important, rewriting or compacting early messages mid-session changes the prompt prefix from the first edited token onward, invalidating your prompt cache.

5. Reuse Stable Prefixes with Prompt Caching

What to do: Structure prompts so static content—system instructions, tool definitions, and reference documents—sits at the very beginning, and dynamic user input sits at the end.

  • OpenAI (prompt caching guide): Enabled by default on GPT-5.6 and later (including the GPT-6 family) for visible prefixes of at least 1,024 tokens. Cache reads cost 0.1× base input on most models and 0.05× on GPT-6.1 Sol and GPT-6.1 Terra. Writes cost 1.25× for the default 30-minute lifetime ("30m") or 2.5× for an optional 12-hour lifetime ("12h" in the Responses API). Using OpenAI’s 0.1× read / 1.25× write math, writing once and reusing once costs 1.35× base input (versus 2× uncached), and one write followed by nine reads costs 2.15× (versus 10× uncached).
  • Anthropic (prompt caching documentation): Opt in with cache_control (up to 4 breakpoints; 20-block lookback window). Minimum cacheable length is 512 tokens on Claude Opus 5.5, Sonnet 5.5, and Haiku 5.5. Writes cost 1.25× for the default 5-minute TTL (refreshed at no extra cost on each hit) or 2× for the 1-hour TTL. Reads cost 0.05× base input on Opus 5.5 and Sonnet 5.5, and 0.1× on Haiku 5.5. Unlike OpenAI, Anthropic cache hits are not deducted against rate limits.
  • Google Gemini 4 Argon: Supports implicit caching only (explicit caching is not supported), billing cache hits at $0.10/M through Nov 30, 2026 and $0.20/M starting Dec 1, 2026.

For implementation patterns and prefix layout rules, see our dedicated guide on what prompt caching is and how it works.

  • When it works: High-traffic endpoints sharing large system prompts, many-shot examples, tool schemas, or multi-turn agents that strictly append new turns.
  • When it fails: Prompts shorter than the minimum threshold (1,024 tokens on GPT-6 models; 512 tokens on Claude 5.5 models); prefixes broken by dynamic timestamps at the top or non-deterministic JSON key ordering; or low-traffic endpoints where the TTL expires before a second request arrives (leaving you paying 1.25× to 2.5× for a cache write that never hits). Changing tools, model, structured-output schema, or reasoning.effort can also break prefix matching (though OpenAI provides configuration_update on GPT-6 to adjust effort without rewriting the hidden prefix).

6. Move Asynchronous Workloads to Batch APIs

What to do: Route any workload that does not require an immediate response—whether overnight test suites, corpus classification, or background metadata generation for creative pipelines like AI Studio Video—through asynchronous batch endpoints for a 50% discount off standard prices (checked 2026-11-08):

  • OpenAI (Batch API guide): 50% off standard input and output (for example, GPT-6.1 Sol drops to $1.00/$5.00; GPT-6 Luna drops to $0.05/$0.25) with a 24-hour completion_window and a separate rate-limit pool. Accepts up to 50,000 requests or 200 MB per batch.

  • Anthropic (Message Batches API): 50% off standard input and output (Sonnet 5.5 drops to $1.00/$5.00; Opus 5.5 to $2.00/$10.00; Haiku 5.5 ≤100K to $0.05/$0.25). Supports up to 100,000 requests or 256 MB per batch, with a 24-hour expiration window (most batches finish in under an hour). Prompt-caching discounts can stack with batch pricing, though batch cache hits are best-effort (Anthropic notes typical hit rates range from 30% to 98% depending on traffic).

  • Google Gemini 4 Argon Batch: 50% off standard rates—$1.00 input / $5.00 output (and $0.05 cached input) through Nov 30, 2026, rising to $2.00 input / $10.00 output ($0.10 cached) on Dec 1, 2026.

  • When it works: Offline evals, dataset labeling, nightly backfills, and bulk document processing.

  • When it fails: Interactive chat, live user autocomplete, and synchronous agent loops. Also remember that 24 hours is an expiration deadline, not a guaranteed SLA: if an OpenAI batch expires before finishing, unfinished requests are canceled and you are still billed for the requests that completed. On Anthropic, batches are not eligible for Zero Data Retention (ZDR) because of asynchronous storage.

7. Configure Spend Alerts Before Hard Quota Caps

What to do: Separate early-warning notifications from hard circuit breakers in your provider console. As detailed in the OpenAI spend limits documentation, you can configure budgets at both the Organization level and the individual Project level:

  • Spend alerts send an email notification when a threshold is crossed while allowing API traffic to continue uninterrupted.
  • Hard spend limits reject subsequent requests with HTTP 429 (organization_spend_limit_exceeded or project_spend_limit_exceeded). These are distinct from your monthly usage-tier cap (organization_usage_limit_exceeded) and prepaid balance depletion (credit_balance_exhausted).

Set multiple spend alerts (for example, at 50% and 80% of your expected monthly project budget) and reserve the hard limit for true runaway-loop protection.

  • When it works: Every multi-project team and any application with automated retry logic or background workers.
  • When it fails: Relying on alerts alone will not stop a weekend infinite loop if nobody checks email. Conversely, setting a tight hard spend limit on a customer-facing production project will cause an outage (429 errors) the moment traffic spikes. Note also that enforcement is not instantaneous—both OpenAI’s spend-limit docs and Anthropic’s batch docs warn that high-throughput workloads can slightly overshoot a configured spend limit before throttling kicks in.

Frequently Asked Questions

Why did my AI API bill jump when my visible replies stayed short?

Reasoning and thinking models bill for internal chain-of-thought tokens at the model’s full output rate. Even if the visible JSON or text reply is only 100 tokens, the model may generate thousands of hidden reasoning tokens first. Check output_tokens_details.reasoning_tokens on OpenAI or thinking usage on Claude and Gemini, and lower the reasoning effort parameter for simple tasks.

Does prompt caching always lower AI API costs?

No. On both OpenAI and Anthropic, writing to the cache carries a 1.25× to 2.5× input multiplier depending on the time-to-live (TTL) you select. If your traffic is too sparse to read that prefix before the TTL expires—or if a dynamic timestamp at the top of the prompt breaks prefix matching—you pay the write premium without getting discounted reads.

What is the difference between a spend alert and a hard spend limit?

A spend alert only sends a notification when usage crosses your threshold; live requests keep succeeding. A hard spend limit actively blocks further API calls—returning HTTP 429 errors such as project_spend_limit_exceeded on OpenAI—to stop runaway billing. Use staggered alerts for routine budget monitoring and set hard limits per project as a safety ceiling.

Sources

All prices, multipliers, token minimums, and product limits in this guide were verified on 2026-11-08 against the official documentation below:

Written by

Chunyu Cai

Chunyu Cai is the CEO of Lotook, LLC and an entrepreneur who writes about AI models, agents, and how they change everyday work. Chunyu holds a master's degree from Imperial College London.