Block VII · What it costs and what suits you · Lesson 36

API prices: how to pay much less

You'll learn the techniques that cut API costs the most: prompt caching, batch processing at a 50% discount, sending easy tasks to cheap models and comparing providers from a single place.

Go to the course

What you'll see in this lesson

  1. Where the money goes in the API

    You pay for every input and output token in every call, and most of it is usually text you send again and again.

  2. Prompt caching: pay once for what you repeat

    If the start of the prompt is identical across several calls, the provider stores it and charges you a fraction of the price.

  3. How it works at OpenAI, Anthropic and Google

    All three offer caching with discounts of 90 % or more on reads, but each one turns it on and charges for it its own way.

  4. Order your prompt to hit the cache

    Put what never changes at the top and what changes every call at the bottom: that way the prefix always matches.

  5. Batches: half price if you can wait

    OpenAI, Anthropic and Google charge 50 % less if you accept getting the replies within a few hours, a day at most.

  6. Send easy tasks to cheap models

    Between the most expensive and the cheapest model from the same provider, prices differ by 40 to 100 times.

  7. OpenRouter: compare providers from one place

    With a single key you get hundreds of models from many providers, and you can ask it to always pick the cheapest.

  8. Set a spending cap before you need it

    A badly coded loop or a leaked key can burn hundreds of euros in one night: set limits from day one.

  9. Summary

    Combine caching, batches and routing, compare providers and protect your account with caps: your bill can drop to a fraction.

Tools and concepts

Sign in with your Google account to access this lesson and the whole course.

Go to the courseSee the full syllabus

More lessons in this block