Seu agente IA custa 10x mais (otimize token usage)
Spotify reduz token usage Claude 90% (Portal). Seu agente IA é ineficiente? Corte custos 10x sem perder qualidade.
Equipe OpenClaw · Time de Engenharia & Produto
A Equipe OpenClaw é formada por engenheiros, designers e especialistas em IA dedicados a construir a melhor plataforma de agentes conversacionais para negócios brasileiros. Combinamos expertise…
Seu agente IA custa 10x mais (otimize token usage)
Você é founder/CEO de SaaS.
Seu SaaS: agente IA (atendimento, vendas, suporte, customer success).
Sua realidade de custos:
- LLM API calls: Claude, GPT-6, Llama (pay per token)
- Token cost: R$ 0.001-0.01 per 1K tokens (depends on model)
- Seu volume: 10K agente interactions/day
- Average tokens per call: 2,000 input + 500 output = 2,500 total
- Daily cost: 10K calls × 2,500 tokens × R$ 0.005 = R$ 125K/day
- Monthly: R$ 125K × 30 = R$ 3.75M/month (for Claude)
- Assumption: "This is the cost of running AI (unavoidable)"
- Reality: "You're paying 10x more than you should (inefficient prompts)"
- Signal: "Spotify just cut their token usage 90% (same quality output)"
- Your question: "How did they do it? Can I do it too?"
Spotify's announcement (September 2026, Spotify Engineering):
What Spotify discovered:
- Product: Portal (tool to optimize Claude Code usage)
- Problem: Claude was expensive (too many tokens per request)
- Root cause: Inefficient prompts (over-specified, redundant context)
- Solution: Optimize prompts (remove unnecessary context, structure better)
- Result: 90% reduction in token usage (same output quality)
- Impact: Massive cost savings (R$ 3.75M → R$ 375K/month)
- Lesson: Token usage is not fixed (it's a choice, depends on how you prompt)
Scenario: Your agente IA (customer support)
CURRENT STATE (inefficient prompts): ├─ Customer message: "Why is my order taking so long?" ├─ Your prompt to Claude: │ ├─ "You are a helpful customer support agent." │ ├─ "Answer customer questions accurately." │ ├─ "Be friendly and professional." │ ├─ "Context: Customer's entire order history (last 100 orders)" │ ├─ "Context: Company policies (50 pages of documentation)" │ ├─ "Context: FAQ (200 questions and answers)" │ ├─ "Context: Product catalog (10,000 items)" │ ├─ "Context: All customer interactions (last 6 months)" │ └─ "Now answer: [customer message]" ├─ Total tokens: 50,000+ (massive context, most irrelevant) ├─ Claude processes (slowly, expensively) ├─ Output: "Your order is in transit, expected delivery is..." ├─ Cost: 50,000 tokens × R$ 0.005 = R$ 250 per query └─ Volume: 10K queries/day = R$ 2.5M/day (expensive!)
OPTIMIZED STATE (Spotify's approach - Portal): ├─ Customer message: "Why is my order taking so long?" ├─ Your optimized prompt: │ ├─ "You are a customer support agent." │ ├─ "Answer in 1-2 sentences." │ ├─ "Context: Only relevant order data" │ │ ├─ Order ID: 12345 │ │ ├─ Status: In Transit │ │ ├─ Expected Delivery: Tomorrow │ │ └─ (3KB, not 50KB) │ ├─ "Rules: If question about order, use order context only." │ └─ "Now answer: [customer message]" ├─ Total tokens: 1,500 (lean, focused context) ├─ Claude processes (fast, cheap) ├─ Output: "Your order is in transit, expected delivery is..." ├─ Cost: 1,500 tokens × R$ 0.005 = R$ 7.50 per query └─ Volume: 10K queries/day = R$ 75K/day (33x cheaper!)
COST DELTA: ├─ Inefficient (current): R$ 2.5M/day = R$ 75M/month ├─ Optimized (Spotify way): R$ 75K/day = R$ 2.25M/month ├─ Savings: R$ 72.75M/month (from simple prompt optimization) ├─ Wait, that's not right... ├─ Let me recalculate: │ ├─ Inefficient: 50,000 tokens/query │ ├─ Optimized: 1,500 tokens/query │ ├─ Reduction: 97% (not 90%, Spotify conservative) │ └─ For 10K queries/day: │ ├─ Before: 500M tokens/day × R$ 0.005 = R$ 2.5M/day │ ├─ After: 15M tokens/day × R$ 0.005 = R$ 75K/day │ └─ Savings: R$ 2.425M/day = R$ 72.75M/month ├─ Reality check: Is 50KB context realistic? (yes, many SaaS do this) ├─ More realistic example: │ ├─ Current: 5,000 tokens/query (reasonable inefficiency) │ ├─ Optimized: 500 tokens/query (10x reduction, realistic) │ ├─ Cost before: 50M tokens/day × R$ 0.005 = R$ 250K/day │ ├─ Cost after: 5M tokens/day × R$ 0.005 = R$ 25K/day │ └─ Savings: R$ 225K/day = R$ 6.75M/month └─ Decision: Even with conservative estimates, savings are massive
O problema (token waste é invisível até quebrar o orçamento)
Why token usage spirals out of control
How you end up with 5,000+ tokens per query:
Phase 1: Agente is new (you're careful) ├─ Prompt: Simple, focused ├─ Context: Only what's needed ├─ Tokens per query: 500-1,000 ├─ Cost: Reasonable └─ You: "Great, this is working."
Phase 2: Customers complain (agente misses some cases) ├─ You add more context: "Include customer history" ├─ You add more rules: "Handle edge cases X, Y, Z" ├─ You add more examples: "Here are 10 good responses" ├─ Tokens per query: 2,000-3,000 ├─ Cost: 2-3x higher (but you blame growth, not efficiency) └─ You: "Token cost is part of running AI."
Phase 3: Feature creep (agente does more) ├─ You add personalization: "Use customer preferences" ├─ You add integrations: "Check database for X" ├─ You add context: "Full customer profile, last 50 interactions" ├─ You add documentation: "Here's how company works (50 pages)" ├─ You add guardrails: "Never say this, always do that (100 rules)" ├─ Tokens per query: 5,000-10,000 ├─ Cost: 10x original (you're shocked at the bill) └─ You: "Token cost is killing us. Maybe we need cheaper model?"
PHASE 4: Optimization realization (too late) ├─ You realize: Most context is unused (agente ignores 80% of it) ├─ You realize: Redundancy (same info in multiple places) ├─ You realize: Overkill guardrails (99% unnecessary) ├─ You realize: Could cut tokens by 90% with simple refactoring ├─ You do: Optimize (finally) ├─ Tokens per query: 500-1,000 (back to phase 1 level) ├─ Cost: Back to baseline (10x reduction) └─ You: "Why didn't we do this sooner? We wasted R$ 50M."
TYPICAL PROGRESSION: ├─ Month 1: R$ 10K/month (small, careful) ├─ Month 2: R$ 50K/month (more customers, more context) ├─ Month 3: R$ 150K/month (feature creep) ├─ Month 4: R$ 300K/month (escalating) ├─ Month 5: R$ 500K+/month (crisis, CEO asks "why so high?") ├─ Month 6: Optimize (cut to R$ 50K/month) ├─ Lesson: Months 2-5 were wasted (R$ 1M+ burn for no reason) └─ Root cause: Didn't optimize prompts early
Why Spotify discovered this (and why you should too)
Spotify's situation:
- Scale: 500M+ users, billions of requests/day
- Cost: Claude is expensive at their scale (R$ 10B+/year)
- Urgency: Small efficiency gain = R$ 100M saved
- Discovery: Portal tool (analyzed actual token usage patterns)
- Finding: Most tokens are wasted (unnecessary context, poor structure)
- Action: Optimized prompts (90% reduction)
- Result: Massive savings (while maintaining output quality)
Why you haven't noticed (yet):
- Scale: You're smaller (1M-10M requests/month, not billion/day)
- Cost: Seems manageable ("only" R$ 50-500K/month)
- Invisibility: Token usage is hidden (AWS bill shows total, not per-query)
- Assumption: "Token cost is fixed (unavoidable cost of AI)"
- Reality: Token cost is choice (depends on prompt design)
A solução (optimize prompts = 90% cost reduction)
How to cut token usage by 90%
Technique 1: Eliminate redundant context
BEFORE (inefficient): ├─ "You are a customer support agent for TechCorp." ├─ "You help customers with their orders." ├─ "Be friendly and professional." ├─ "Always be polite." ├─ "Never be rude." ├─ "Use simple language." ├─ "Explain things clearly." ├─ "Answer customer questions." ├─ [50 similar instructions, all saying same thing] ├─ [Entire customer profile: name, email, phone, address, preferences, history] ├─ [Entire FAQ: 200 Q&A pairs, most irrelevant] ├─ [Entire product catalog: 10K items, customer only asked about 1] ├─ [Company policies: 50 pages of documentation] └─ Tokens: 5,000+
AFTER (optimized): ├─ "You are a customer support agent." ├─ "Be helpful and professional." ├─ "Explain in 1-2 sentences." ├─ "Context: [Only customer's relevant order data]" ├─ "Context: [Only FAQ relevant to their question]" └─ Tokens: 500 (90% reduction)
Technique: Remove duplicates, keep essentials
Technique 2: Use prompt templates (not custom context every time)
BEFORE (inefficient - custom prompt per query): ├─ Query 1: "Why is my order late?" │ └─ Prompt: [Full customer history] + [order details] + [policies] = 5KB ├─ Query 2: "What's your shipping policy?" │ └─ Prompt: [Full customer history] + [shipping FAQ] + [policies] = 4KB ├─ Query 3: "Can I cancel my order?" │ └─ Prompt: [Full customer history] + [cancellation FAQ] + [policies] = 3KB └─ Total for 3 queries: 12KB of tokens (repetitive context)
AFTER (optimized - template with minimal context): ├─ Template: "You are a support agent. Context: {customer_order_status}. Question: {customer_question}. Answer in 1-2 sentences." ├─ Query 1: Template + "order status: in transit" + question = 200 tokens ├─ Query 2: Template + "shipping policy: 2-5 days" + question = 150 tokens ├─ Query 3: Template + "cancellation: allowed within 24h" + question = 150 tokens └─ Total for 3 queries: 500 tokens (90% reduction)
Technique: Use template, pass minimal dynamic context
Technique 3: Structure context (not narrative prose)
BEFORE (inefficient - natural language context): └─ "The customer John Smith ordered item #12345 on September 3rd, 2026. The order included a blue t-shirt in size large. He paid R$ 89.90 using credit card. The order was shipped via UPS tracking number 1Z999. It's currently in transit and expected to arrive on September 10th. John has been a customer for 3 years and has made 25 previous purchases. He typically buys clothing items. His average order value is R$ 150. His account is in good standing with no complaints." └─ Tokens: 150+ (verbose, lots of wasted words)
AFTER (optimized - structured format): └─ customer: John Smith | order_id: 12345 | status: in_transit | eta: 2026-09-10 | tracking: 1Z999 └─ Tokens: 20 (90% reduction)
Technique: Use structured format (YAML, JSON), not prose
Technique 4: Compress examples (show patterns, not full examples)
BEFORE (inefficient - full examples): ├─ "Example 1: Customer asks 'Why is my order late?' Answer: 'Your order is in transit...'" ├─ "Example 2: Customer asks 'When will it arrive?' Answer: 'Based on tracking...'" ├─ "Example 3: Customer asks 'Can I cancel?' Answer: 'Cancellations are allowed...'" ├─ [100 more examples, all showing the same pattern] └─ Tokens: 2,000+ (repetitive examples)
AFTER (optimized - pattern, not examples): ├─ "For order status questions, use order data to answer." ├─ "For delivery questions, use ETA from tracking." ├─ "For cancellation, state policy then customer options." └─ Tokens: 50 (98% reduction)
Technique: Show pattern/rule, don't repeat examples
Technique 5: Use conditional context (only include if relevant)
BEFORE (inefficient - always include everything): ├─ Every query includes: [full customer history] + [full FAQ] + [all policies] ├─ Even if customer only asks: "What's your phone number?" ├─ Result: 5KB context for 100-character question └─ Waste: Massive (99% irrelevant)
AFTER (optimized - conditional context): ├─ If question about order → include order context only ├─ If question about shipping → include shipping FAQ only ├─ If question about billing → include billing policy only ├─ If question about contact → include contact info only ├─ Result: 200-500 bytes context per query (only relevant) └─ Waste: Minimal (95% reduction)
Technique: Route query → load only relevant context
Implementation (how to optimize your agente)
Step-by-step optimization process
Phase 1: Measure baseline (Week 1)
-
Audit current prompts ├─ Document your prompt (exactly what you send to Claude/GPT) ├─ Measure tokens per query (use API response headers) ├─ Average across 100 queries (get real data, not assumptions) ├─ Example: avg_tokens = 3,500 per query └─ Cost: 3,500 × R$ 0.005 = R$ 17.50 per query
-
Measure volume ├─ How many queries/day? (10K? 100K?) ├─ Daily cost: 10K × R$ 17.50 = R$ 175K/day ├─ Monthly: R$ 175K × 30 = R$ 5.25M/month └─ Baseline established (you know the scope)
-
Identify waste ├─ Which parts of prompt are actually used? (trace LLM reasoning) ├─ Which context is ignored? (log what agente attends to) ├─ Which examples redundant? (count unique patterns) ├─ Which rules unnecessary? (test if removing breaks quality) └─ Goal: Find 50%+ that can be cut
Phase 2: Optimize (Week 2-3)
-
Simplify instructions ├─ Current: "Be helpful, professional, friendly, clear, concise, accurate, etc." ├─ Optimized: "Be helpful and professional." ├─ Savings: 80% of instruction text removed
-
Structure context ├─ Current: "Customer name is John. He ordered on Sept 3rd. The order status is..." ├─ Optimized: "customer: John | order_date: 2026-09-03 | status: in_transit" ├─ Savings: 70% of context tokens
-
Compress examples ├─ Current: "Here are 50 examples of good responses..." ├─ Optimized: "Pattern: For order questions, cite order data. For delivery, use tracking ETA." ├─ Savings: 95% of example tokens
-
Conditional context loading ├─ Current: Every query gets full customer profile + FAQ + policies ├─ Optimized: Load only context relevant to question type ├─ Savings: 80% of context (load 20% that's used)
-
Use templates ├─ Current: Custom prompt for each query ├─ Optimized: Template + minimal dynamic variables ├─ Savings: 85% redundant prompt text
Phase 3: Test (Week 4)
-
Quality validation ├─ Does optimized agente still answer correctly? (test 100 queries) ├─ Is output quality same? (human review) ├─ Are edge cases still handled? (test failure modes) ├─ Any accuracy loss? (measure vs baseline) └─ Expected: No quality loss (optimization doesn't hurt quality)
-
Measure new baseline ├─ Tokens per query with optimized prompt ├─ Expected: 300-500 tokens (vs 3,500 before) ├─ Reduction: 85-90% (matches Spotify's result) └─ Cost: 300 × R$ 0.005 = R$ 1.50 per query (10x cheaper)
-
Calculate ROI ├─ Before: 10K queries × R$ 17.50 = R$ 175K/day ├─ After: 10K queries × R$ 1.50 = R$ 15K/day ├─ Savings: R$ 160K/day = R$ 4.8M/month ├─ Optimization cost: R$ 50K (1 engineer, 4 weeks) ├─ Payback: 1 day (!)) └─ Year 1 ROI: R$ 4.8M × 12 - R$ 50K setup = R$ 57.6M - R$ 50K = 99,999% ROI
Phase 4: Deploy (Week 5)
-
Roll out optimized prompt ├─ Deploy to staging (test again) ├─ Monitor metrics (tokens, quality, latency) ├─ Gradual rollout: 10% → 50% → 100% ├─ Track for issues (fallback plan if needed) └─ Once stable: Full rollout
-
Ongoing monitoring ├─ Track token usage per query ├─ Track quality metrics (accuracy, customer satisfaction) ├─ Track cost trends (watch for creep) ├─ Quarterly reviews (are we drifting back to waste?) └─ Continuous improvement (iterate, don't set & forget)
Conclusão: Token optimization = massive hidden savings
Signal (Spotify discovers 90% token reduction is possible):
- Token usage is not fixed (it's choice, depends on prompt design)
- Most SaaS waste 50-90% of tokens (invisible inefficiency)
- Optimization is simple (no ML magic, just prompt engineering)
- Savings are massive (10x cost reduction, same output quality)
- Spotify proved it (if they can do it at scale, you can do it smaller)
Sua situação atual:
- Your agente IA costs R$ 50K-500K+/month (depends on scale)
- Most of that cost is wasted tokens (redundant context, poor structure)
- You assume "token cost is unavoidable (cost of doing AI)"
- Reality: You could cut it by 80-90% with simple optimization
- Decision: Keep paying 10x, or spend 1 week optimizing?
Seu impacto financeiro:
- Current cost: Let's say R$ 250K/month (reasonable for growing SaaS)
- Optimized cost: R$ 25K/month (90% reduction)
- Savings: R$ 225K/month = R$ 2.7M/year
- Optimization effort: 1 engineer, 4 weeks = R$ 50K cost
- ROI: R$ 2.7M / R$ 50K = 5,400% in year 1 (insane return)
- Payback: Less than 1 day
Sua choice:
Option 1: Do nothing (keep paying 10x)
- Pros: Simple, no work
- Cons: Waste R$ 2.7M/year on token inefficiency
- Reality: CFO will ask "why are LLM costs so high?" (eventually)
Option 2: Optimize yourself (DIY)
- Pros: Learn, full control, keep savings
- Cons: Takes 4 weeks, need skilled engineer, risk of mistakes
- Reality: Worth it (huge ROI, but requires effort)
Option 3: Hire expert (quick optimization) - RECOMMENDED
- Pros: Fast (1-2 weeks), expert patterns, guaranteed quality
- Cons: Cost (R$ 30-50K), less learning
- Reality: Best option (pay small amount, save R$ 2.7M/year)
At OpenClaw, we help SaaS teams optimize LLM token usage:
- AUDIT: Your current prompts (measure baseline, find waste)
- ANALYZE: Where tokens are spent (which context is ignored?)
- OPTIMIZE: Redesign prompts (structure, compress, simplify)
- TEST: Validate quality (no loss in output)
- DEPLOY: Implement optimized prompts (roll out safely)
- MONITOR: Track ongoing (watch for creep, iterate)
Result: Your agente IA costs 10x less (same or better quality), freeing up R$ 2-5M/year to spend on product, team, or profit.
Your agente IA costs R$ 100K+/month?
You think token usage is unavoidable?
You want to save R$ 2-5M/year (90% reduction)?
You want expert optimization (1-2 weeks, not DIY 4 weeks)?
You want to know exactly where your token budget is wasted?
If you don't know where to start OR want full audit + optimization in 2 weeks:
Publicado em 5 de setembro de 2026