Get your API key

Lesson 4 of 5

Read your usage, cap your spend

One key per project with a monthly limit, reading usage by model and by key, and finding the costly requests.

7 min Log in to open
One step at a time, like flipping pages.

By the end of this lesson every project will have its own API key with a monthly spend limit, and you will know how to read your usage to find what is costing money, before the bill surprises you.

You need: an AllModelAPI account (or any provider's dashboard), the coding agent you use for your project · Time: 7 minutes

  1. An API key is the password your tools use to call a model. If one key is shared by everything (your coding agent, the fee tracker app, a test script), you cannot tell who spent what, and one runaway loop can use the whole month's money.

    So make one key per project and per use, for example:

    • fee-tracker-agent: the coding agent building the fee tracker.
    • fee-tracker-app-test: the app itself on your laptop and previews.
    • fee-tracker-app-live: the live app, created only when you launch.

    On AllModelAPI, open API keys and click Create API key:

    1. Key name: a clear name like fee-tracker-agent.
    2. Turn on Spend limit. The amount is in US dollars, Per month. It starts at a big number, so change it to what you planned, for example $5 for a weekend build. Requests stop automatically when this limit is reached.
    3. Keep Notify me at 80% usage ticked.
    4. Create it, then copy the key. It is shown only once, so paste it straight into your tool's settings or your .env file, never into a chat or a commit (Keep secrets secret).
    Do it now

    Do it now

    Careful

    A key without a limit is an open wallet. Agents can loop (try, fail, try again) for hours, and a leaked key can be used by strangers. A limit turns both into a small, known loss.

    Why?

    Separate keys answer "who spent this?" at a glance, and a monthly limit on each one means a mistake in one project can never eat the budget of another.

Log in free to read the rest of this lesson

Every lesson is free. A free account unlocks all of them and saves your progress.

Still to come in this lesson:

  1. What happens at the limit
  2. Read your usage in two minutes
  3. Find the costly requests
  4. A five-minute money check every week
  5. Recap