Your AI Bill Has Two Dials. You Are Probably Only Turning One.
Summary
AI billing for metered API usage is driven by two factors: cost per token and tokens per task. While many teams prioritize reducing cost per token by selecting cheaper models, the article emphasizes that optimizing "tokens per task" offers significantly larger, multiplicative savings. This second dial is controlled by four key levers: compression, retrieval-augmented generation (RAG), caching, and smart routing. For instance, OpenAI provides automatic caching for prompts over 1,024 tokens, offering a 90% discount on cached input reads, while Anthropic offers developer-controlled caching with similar savings. Both providers also offer a 50% discount for asynchronous batch processing. The article clarifies that these optimization strategies apply specifically to pay-as-you-go API models, not flat-fee subscriptions like ChatGPT Plus, where cost optimization focuses on plan selection and seat usage.
Key takeaway
For AI Architects or MLOps Engineers managing LLM API costs, prioritize optimizing "tokens per task" over merely seeking cheaper models. You should measure input/output tokens per task to identify expensive workflows, then implement caching, compression, RAG, and smart routing. These strategies offer multiplicative savings, ensuring your unit economics improve with success rather than degrade. Focus on building token-spending discipline, as this yields greater long-term cost control than one-time model price negotiations.
Key insights
Optimizing "tokens per task" through compression, RAG, caching, and routing yields multiplicative AI cost savings.
Principles
- AI billing is a product of cost per token and tokens per task.
- Cost optimization levers stack multiplicatively, not additively.
- Match model difficulty to task, not the other way around.
Method
Implement caching by placing stable content first in prompts. Utilize batch APIs for non-real-time workloads. Apply routing, compression, and RAG within application code to reduce tokens per task.
In practice
- Use OpenAI's automatic caching for prompts >1,024 tokens.
- Implement Anthropic's `cache_control` for explicit caching.
- Move nightly jobs to batch APIs for 50% cost reduction.
Topics
- LLM Cost Optimization
- Token Management
- Prompt Caching
- Retrieval-Augmented Generation
- Model Routing
- Batch Processing
Best for: Director of AI/ML, AI Architect, MLOps Engineer
Related on AIssential
See Counsel's argued verdicts on the open AI decisions leaders are weighing →
Editorial summary, takeaway, and curation by AIssential. Original article published by LLM on Medium.