API Gateway Pricing Breakdown: What You're Really Paying for LLM Inference
If you're running LLMs in production, you've probably noticed something uncomfortable: your API bill doesn't match the nice per-token pricing on the provider's website. Between gateway fees, data transfer costs, and markup from intermediaries, the real cost of LLM inference is often 20-40% higher than the advertised token price.
This guide breaks down every component of API gateway pricing for LLM inference, compares the major cloud providers and API gateways, and shows you practical strategies to bring your actual spend back in line with what you thought you were paying.
The Anatomy of LLM API Costs
When you call an LLM API, you're not just paying for tokens. Your total cost has multiple layers:
- Token costs — the per-million-token rate for input and output tokens. This is the price everyone quotes, but it's only part of the picture.
- API gateway fees — if you route through AWS API Gateway, Azure API Management, or a similar service, you pay per-request fees on top of the token cost.
- Data transfer — cloud providers charge for egress. LLM responses (especially streaming ones) generate non-trivial bandwidth.
- Idle infrastructure — load balancers, NAT gateways, and VPC endpoints all have baseline costs whether you're making requests or not.
- Retry overhead — rate limits and transient errors mean real-world applications make 5-15% more API calls than they would in an ideal environment.
Let's put numbers on each of these.
Token Pricing: The Baseline You Already Know
As of early 2026, here's what the major providers charge for their flagship models:
| Provider | Model | Input / 1M tokens | Output / 1M tokens |
|---|---|---|---|
| OpenAI | GPT-4.5 | $75.00 | $150.00 |
| OpenAI | GPT-4o | $2.50 | $10.00 |
| Anthropic | Claude Opus 4 | $15.00 | $75.00 |
| Anthropic | Claude Sonnet 4 | $3.00 | $15.00 |
| Gemini 2.5 Pro | $1.25 | $10.00 | |
| DeepSeek | DeepSeek V3 | $0.27 | $1.10 |
| Mistral | Mistral Large | $2.00 | $6.00 |
These numbers are well-publicized. What's less obvious is how much additional cost sits on top of them when you build a production system.
API Gateway Costs: The Hidden Layer
Most production deployments don't call LLM providers directly from application code. They route through an API gateway for auth, rate limiting, logging, and observability. Here's what that costs on the major clouds:
AWS API Gateway
AWS offers two flavors: REST APIs and HTTP APIs. For LLM proxying, you'll almost certainly want HTTP APIs (cheaper and faster), but many teams end up on REST APIs because they started there or needed features only available in REST.
| Type | Cost per million requests | Data transfer (per GB) |
|---|---|---|
| REST API | $3.50 | $0.09 |
| HTTP API | $1.00 | $0.09 |
| WebSocket API | $1.00 + $0.25/million messages | $0.09 |
At 1 million LLM requests per month (not uncommon for a mid-size product), you're adding $1,000-3,500/month just for the gateway, before any token costs. The data transfer adds up too: if your average response is 2KB, that's 2GB of egress, or another $0.18. Not huge, but it scales.
Azure API Management
Azure's pricing is tier-based rather than purely per-request:
| Tier | Monthly base cost | Included requests |
|---|---|---|
| Consumption | $0 base | $3.50 per million requests |
| Developer | $49/month | Unlimited (not for production) |
| Standard | $700/month | Unlimited |
| Premium | $2,800/month | Unlimited |
The "Standard" tier looks attractive for high-volume use cases, but it requires a dedicated instance, which means you're paying $700/month even during quiet periods. The Consumption tier is more comparable to AWS HTTP API pricing.
GCP API Gateway
Google Cloud's API Gateway charges $3.00 per million requests for the first billion, then $1.50/million after that. They also charge $0.09/GB for data processed. GCP's Apigee (their full-featured API management platform) starts at $500/month for the Standard tier.
What This Means in Practice
Let's model a real scenario. Say you're a B2B SaaS running 500,000 LLM requests per month, using mostly GPT-4o and Claude Sonnet 4, with an average of 500 input tokens and 800 output tokens per request:
| Cost component | Monthly cost |
|---|---|
| Token costs (blended) | $4,500 |
| AWS HTTP API Gateway | $500 |
| Data transfer | $85 |
| NAT Gateway (fixed) | $32 |
| CloudWatch logs | $45 |
| Retry overhead (~8%) | $360 |
| Total | $5,522 |
That's a 22.7% markup over the bare token cost. And this is a relatively efficient setup. Teams using REST APIs, running dedicated gateway instances, or paying for additional monitoring often see 30-40% overhead.
Third-Party API Gateways and Aggregators
If you're not building your own gateway, you might use a third-party LLM router or aggregator. These services offer convenience (one API key, multi-provider access, fallback routing) but add their own margins:
| Service | Pricing model | Typical markup |
|---|---|---|
| OpenRouter | Pass-through + margin | 5-20% depending on model |
| Portkey | Per-request fee | $0.30 per 1K requests |
| Helicone | Free tier + usage | Variable (logging-focused) |
| LiteLLM | Open source (self-hosted) | 0% (but you pay infra) |
Self-hosted options like LiteLLM eliminate the markup but shift the operational burden to you. You're trading money for engineering time—which may or may not be the right tradeoff depending on your team size and request volume.
The Real Cost Drivers Most Teams Miss
Beyond the obvious per-request and per-token fees, several factors inflate LLM costs in ways that don't show up in simple pricing calculators:
1. Output tokens cost 2-5x more than input tokens
This is the most overlooked aspect of LLM pricing. Output tokens are consistently more expensive than input tokens across all providers. With GPT-4o, outputs cost 4x the input rate. With Claude Opus 4, it's 5x. If your application generates long responses (code generation, detailed analysis, creative content), your effective per-request cost is much higher than a naive calculation based on input length would suggest.
2. Streaming adds connection overhead
Server-sent events (SSE) streaming is great for UX but creates longer-lived connections. On AWS, this means more NAT Gateway processing time and potentially higher load balancer costs. A streaming response that takes 8 seconds costs more in gateway/infrastructure terms than a non-streaming response that returns the same content in a single payload.
3. System prompts are repeated on every request
If your application uses a 2,000-token system prompt, that's 2,000 input tokens you're paying for on every single request. At GPT-4o rates ($2.50/1M input tokens), a 2K system prompt adds $0.005 per request. At 500,000 requests/month, that's $2,500/month just for the system prompt. Prompt caching (offered by Anthropic and some other providers) can reduce this significantly.
4. Retries multiply everything
Real-world LLM API calls fail. Rate limits, transient server errors, and timeout issues mean you'll retry a meaningful percentage of requests. Each retry doubles the token cost for that request, and if your retry strategy isn't well-tuned (exponential backoff with jitter), you can end up in retry storms that 10x your expected cost for a period.
5. Development and testing spend
Engineering teams running prompt experiments, testing different models, and debugging production issues generate substantial API usage that's easy to overlook. This "shadow spend" often accounts for 10-20% of a team's total LLM bill.
Strategies That Actually Reduce Costs
Now for the practical part. Here are the strategies that consistently produce measurable savings, ordered by impact and ease of implementation:
1. Intelligent model routing (30-60% savings)
Not every request needs GPT-4.5 or Claude Opus. A simple customer support query that works fine with Gemini Flash or GPT-4o Mini shouldn't be sent to a premium model. Intelligent routing classifies each request by task type and complexity, then routes to the cheapest model that can handle it at the required quality level.
This is the single highest-impact optimization. Teams that implement routing typically see 30-60% cost reduction because the majority of production requests are routine tasks that don't need frontier model capabilities.
2. Response caching (15-25% savings)
Many LLM applications receive similar or identical requests repeatedly. Customer support bots, FAQ systems, and code assistants all have high cache hit potential. A well-implemented cache with semantic similarity matching can eliminate 15-25% of requests entirely.
The key is using both exact match caching (fast, simple) and semantic similarity caching (catches paraphrased versions of the same question). Exact match alone typically catches 5-10%, but adding semantic similarity pushes that to 15-25%.
3. Prompt optimization (10-20% savings)
Most system prompts are longer than they need to be. Techniques like prompt compression, removing redundant instructions, and using few-shot examples efficiently can reduce input token counts by 20-40% without affecting output quality. On a system prompt that runs with every request, this compounds quickly.
4. Provider fallback chains (5-15% savings)
When your primary provider has an outage or rate-limits you, having an automatic fallback to a different provider means you don't lose requests (and therefore revenue). More subtly, it means you can use aggressive rate limits with your primary provider without worrying about failed requests, which can qualify you for volume discounts or preferred pricing.
5. Batch processing where possible (20-50% savings)
If your use case allows async processing (content moderation, bulk classification, data extraction), batch APIs offer significant discounts. OpenAI's batch API is 50% cheaper than real-time. The tradeoff is latency (up to 24 hours), but for offline workloads, it's a clear win.
Total Cost of Ownership: Build vs. Buy
The question every engineering team eventually asks: should we build our own LLM gateway, or use a managed service?
Building your own
| Component | Estimated monthly cost |
|---|---|
| Engineering time (1-2 engineers) | $15,000-$30,000 |
| Infrastructure (servers, DB, Redis) | $500-$2,000 |
| Monitoring and observability | $200-$500 |
| Ongoing maintenance | $3,000-$8,000 |
| Total monthly TCO | $18,700-$40,500 |
This makes sense if you have very specific requirements (custom routing logic, compliance constraints, existing infrastructure) and engineering capacity to maintain it. It doesn't make sense if your primary goal is cost optimization—you'll spend more on the gateway than you save on tokens.
Using a managed LLM proxy
| Component | Estimated monthly cost |
|---|---|
| Service fee / markup | $500-$2,000 |
| Engineering integration time | $500 (one-time) |
| Ongoing management | ~$0 |
| Total monthly TCO | $500-$2,000 |
A managed proxy typically pays for itself many times over through routing savings alone. The math is straightforward: if a proxy saves you 35% on a $10,000/month token bill, that's $3,500 in savings against a $500-$2,000 service cost.
How to Audit Your Current LLM Spend
Before optimizing, you need visibility. Here's a practical checklist for auditing your LLM costs:
- Aggregate all API spend across providers. Most teams use 2-3 providers but only track costs from the primary one.
- Calculate your effective per-token rate by dividing total spend (including infrastructure) by total tokens processed. Compare this to the advertised rate—the gap is your overhead.
- Measure your retry rate. If it's above 5%, your retry strategy needs tuning.
- Profile token usage by endpoint. Usually 2-3 endpoints account for 80% of token spend.
- Check for model over-provisioning. Are you sending simple requests to expensive models? Classification or routing would help.
- Audit development spend. Set up separate API keys or projects for dev/staging to track non-production usage.
What's Next for LLM Pricing
The LLM pricing landscape is evolving rapidly. Several trends are worth watching:
- Prices continue to fall. GPT-4-class performance at GPT-3.5 prices is already here. Expect another 50% reduction in the cost-per-capability ratio over the next 12 months.
- Prompt caching becomes standard. Anthropic pioneered this; others will follow. This eliminates the system prompt cost problem for many use cases.
- Inference-optimized models. Distilled and quantized models (like DeepSeek) offer near-frontier performance at a fraction of the cost. Smart routing to these models is becoming a competitive advantage.
- Edge inference. Running smaller models locally eliminates API costs entirely for suitable tasks. The threshold for "suitable" keeps moving upward.
The Bottom Line
API gateway pricing for LLM inference is more complex than most teams realize. The advertised per-token price is typically 20-40% below your actual cost once you factor in gateway fees, data transfer, retries, and infrastructure overhead.
The good news: most of this overhead is reducible. Intelligent routing alone can save 30-60% by matching requests to the right model. Add caching, prompt optimization, and provider redundancy, and you can cut your effective LLM cost by 40-70% compared to a naive single-provider setup.
The first step is measuring. Until you know where your money is going, you can't fix it.
Cut your LLM costs without changing code
Trovald routes each request to the cheapest model that meets your quality threshold. One API key, 12 providers, 30-60% savings.
Get Started Free