How to Reduce Your AI API Costs
A beginner's guide. No experience required.
1. Why your AI costs might be too high
Most tutorials and quickstart guides default to the most expensive model available. If you followed an OpenAI tutorial, you're probably calling GPT-4o. If you followed an Anthropic tutorial, you're probably calling Claude Sonnet. These are great models, but they're also the priciest.
Here's the thing: for many tasks like classification, data extraction, and simple Q&A, a model that costs 10 to 20x less produces identical results. You're paying flagship prices for work that a smaller model handles just as well.
You won't know which calls are overpaying until you measure them. That's what Clawback does. It watches your API calls, replays them against cheaper models, and tells you exactly where you can save.
2. What you need
- An AI API key (OpenAI, Anthropic, or Google)
- A project that makes API calls (a Python script, a Node.js app, anything)
- A
.envfile in your project (most projects already have one)
3. Setup (step by step)
Step 1: Open your terminal
The terminal is the command line interface on your computer. In VS Code, press Ctrl+` to open it. On Mac, open the Terminal app. On Windows, open PowerShell.
Step 2: Navigate to your project folder
Use the cd command to move into your project directory. Replace my-project with your actual folder name.
cd my-project
Step 3: Run the setup command
curl clawback.run | bash
This adds one line to your .env file. It tells your AI SDK to route calls through Clawback's proxy. Your API key stays on your machine.
Step 4: Enter your email when prompted
This is where your savings report will be sent. You'll get one email with results, nothing else.
Step 5: That's it. Keep using your app normally.
Clawback watches your API calls in the background. After enough calls, it replays each one against cheaper models, scores the quality, and emails you a report.
irm clawback.run | iex
4. What happens next
- Your app works exactly the same. Nothing changes in your code.
- Clawback logs your API calls silently in the background.
- When enough data is collected, it runs the audit automatically.
- You get an email with your savings report within 24 hours.
- The report shows: what you spent, what you could have spent, and the quality difference.
5. Understanding your report
Your savings report breaks down the opportunities it found. Here's what each line means:
- Model routing: $X/mo means X dollars could be saved by using a different model for certain calls. For example, switching a classification task from GPT-4o to GPT-4o-mini.
- Response caching: $X/mo means you're making duplicate calls that could be cached. If you ask the same question twice, there's no reason to pay for it twice.
- Quality: 97%+ means the alternative model produces nearly identical output to what you're using now.
6. Automatic optimization with Clawback Pro
The free audit shows you the problem. Clawback Pro fixes it.
- Pro routes your calls to the right model automatically, in real time.
- Same env var, no additional setup. Flip a switch and it's on.
- You pay 15% of what Clawback saves you. If savings are under $500/mo, you pay nothing.
7. Frequently asked questions
Will this break my app?
No. If you remove the env var, your app goes back to exactly how it was before. Clawback creates a backup of your .env file during setup, so you can always revert.
Can Clawback see my API key?
Your API key stays in your .env file on your machine. Clawback never stores or transmits it. The proxy forwards your requests using the key already on your machine, but the key itself never leaves.
How much does it cost?
The audit is free forever. If you upgrade to Pro and it saves you less than $500/mo, you still pay nothing. There is no credit card required to start.
What if I only make a few API calls?
Clawback needs enough calls to produce a meaningful analysis. Keep building and using your app normally, and the audit will run automatically when there's enough data to work with.