Build Your Own Stuff › Chapter 4

OpenRouter, and keeping your costs sane.

Chapter two was about you talking to an AI. This chapter is about the things you build talking to an AI — automatically, thousands of times, while you sleep. That's where the money goes if you're not careful, and it's entirely avoidable.

What OpenRouter is

OpenRouter is one account and one API key that reaches every major AI model — Claude, Gemini, GPT, Llama, DeepSeek, dozens more — through a single bill. Instead of signing up with five vendors, wrangling five keys and five invoices, you top up one balance and pick whichever model you want, per request, by changing one word in your code.

Two reasons this matters, and the second is the real one.

  1. You can use a cheap model for cheap work. Most of what your automations do is boring: sort this into a category, pull the date out of this email, write a two-line summary. Paying a frontier model to do that is like hiring a surgeon to open your mail. A small fast model does it just as well for a fraction of the cost.
  2. You can have several models check each other. This is the trick that took me longest to find. Have one model write the thing, then hand it to a different model and ask it to find the flaws. Different models fail differently, so one catches what the other missed. The quality gain is real, and it's larger than the gain from just buying the biggest model and trusting it.
The one paid service I recommend

I have a standing rule for my own business: no paid APIs, ever. No paid scrapers, no data vendors, no $200/month enrichment tools. Build it in-house or don't build it. OpenRouter is the single exception I've carved out, because AI models are the one thing you genuinely cannot self-host at quality. Everything else in this guide is free.

Getting started

  1. Sign up at openrouter.ai and add ten dollars. Not a hundred. Ten.
  2. Go to Keys and create a key. It looks like sk-or-v1-....
  3. Put it in a file called .env on your server — never inside the code itself, and never in git.
  4. Ask your agent: "wire this project up to OpenRouter using the key in .env, and default to a cheap model."

Ten dollars will last you a shockingly long time if you follow the next two sections, and if it doesn't, you've learned something important for ten dollars.

Rule one: cascade. Cheap first, expensive only when earned.

Don't pick "the best model" and use it everywhere. Match the model to the job. My standing rule, which lives in my CLAUDE.md so I never have to repeat it:

To make that concrete, here's what the Claude family costs. Prices are per million tokens — a token is roughly three-quarters of a word — split into what you send in and what it writes back out. Output is where the money is, always.

ModelInput / 1MOutput / 1MUse it for
Haiku 4.5$1.00$5.00The workhorse. Classify, extract, summarize, sort. Most of your volume.
Sonnet 5$3.00$15.00The balanced middle. Real writing, real code, most agent work.
Opus 4.8$5.00$25.00Hard reasoning, long autonomous jobs, when being right matters.
Fable 5$10.00$50.00The absolute ceiling. Reach for it deliberately, not by default.
What each model costs to write a million tokens Output cost per million tokens, July 2026. Haiku 4.5 costs five dollars. Sonnet 5 costs fifteen dollars, three times Haiku. Opus 4.8 costs twenty-five dollars, five times Haiku. Fable 5 costs fifty dollars, ten times Haiku. Cost to write 1 million tokens (output), July 2026 Haiku 4.5 $5 the workhorse — most of your volume Sonnet 5 $15 the balanced middle Opus 4.8 $25 hard reasoning only Fable 5 $50 Top to bottom: a 10× spread for the same job.
Every bar is the same task, priced by which model you happened to send it to. Run your routine work through the bottom bar out of habit and you are paying ten times what the top bar costs — for output nobody can tell apart. Prices verified July 2026; check the vendor page before budgeting.

Look at the spread: the top model costs ten times the cheap one on output. If you run everything through the expensive one out of laziness, you are lighting money on fire for no measurable gain on the easy 80% of your work. OpenRouter also carries very inexpensive models from other vendors — check the live prices on their models page, because they change often — and those are frequently the right choice for high-volume grunt work.

The rule I actually use

Cheap model first. If it fails twice, step up. Never default to the expensive one just because it's there. This one habit is the difference between a $15 month and a $400 month, and I have had both.

Rule two: one key per project

This is the single most useful cost-control move and almost nobody does it. Create a separate OpenRouter API key for every project. Not one key for everything. One per thing.

Why it matters: with one shared key, your dashboard shows a single number going up and you have no idea which project is responsible. You feel vaguely anxious about the bill and do nothing, because you can't act on a number you can't attribute. With one key per project, the dashboard shows you exactly which thing is eating the money — and now you can fix it, because you know where to look.

OpenRouter lets you set a spending limit on each individual key. This is the part that turns anxiety into a solved problem:

Now a runaway loop in one experiment burns twenty dollars and stops, instead of quietly draining your whole balance overnight. That is not a hypothetical. That is the thing that happens to everybody once, and the key limit is why it only happens once.

Rule three: watch it for the first week, then stop worrying

When you build something new that calls a model, check the OpenRouter dashboard once a day for the first week. You're looking for one thing: is the shape of the spending what I expected? A pipeline you thought would cost pennies a day and is costing four dollars a day has a bug in it — usually it's being called far more often than you think, or you're sending it enormous amounts of unnecessary text every single time.

Two things that quietly cost more than people expect:

After that first week, if the shape is right, stop watching. The key limit is your safety net. That's what it's for.

Where the real cost is, though

Honestly? For most people reading this, your AI bill is going to be small — twenty or thirty dollars a month, less than one SaaS subscription. The money you're actually bleeding is somewhere else entirely, and that's the next chapter.

← Chapter 3: Teach it how you work Next: Stop paying for software →