One ledger for tokens, models and money across every vendor

AnthropicKeyFreeAPI · Updated 2026-11-22 · 9 min read

Open ledger with a pen, calculator and coins
One ledger beats five dashboards.

Once a project uses more than one model provider, cost visibility falls apart. One dashboard shows month-to-date spend in one format, another in a different one, and the free or local models you use for drafts do not appear anywhere. Developers frequently end up writing small scripts to pull billing numbers together, and some have published open-source tools for exactly this reason. Meanwhile prices and model line-ups shift with every launch, sometimes two flagship releases on the same day, which makes last quarter's comparison stale.

This guide shows a simpler approach: record usage yourself, at the point where your code calls a model, and turn it into cost with a price table you maintain. You get per-feature attribution, a fair comparison between paid, local and free back ends, and early warning before a bill surprises you. AnthropicKeyFreeAPI is not affiliated with Anthropic or any other provider mentioned, and it does not quote their prices; take those from each provider's official pricing page.

Frequently asked questions

What is token-based billing?

Most model APIs charge separately for input tokens, the text you send, and output tokens, the text the model writes. Output is usually priced higher. Your bill is the sum over all requests of tokens multiplied by the rate for that model.

Why not just rely on each provider's dashboard?

Dashboards are accurate for their own provider but cannot tell you which feature, customer or experiment caused the spend, and they do not cover free or local models. Your own log can.

How does logging usage differ from logging prompts?

Usage logging records counts, models, timings and labels, not the content. It is far safer to keep and easy to aggregate. Prompt logging stores the actual text and needs a privacy policy and retention rules.

Where do token counts come from?

OpenAI-compatible APIs return a usage object in the response with prompt and completion token counts. When streaming, some providers only send usage at the end or on request, so check how your client handles it.

Which is cheaper, a local model or a free hosted one?

Both cost nothing per token. A local model costs hardware and electricity; a free hosted one costs you shared limits and no service guarantee. Logging both with a price of zero still shows how much work they absorb.

Should I trust price comparisons from forums?

Use them only as hints. Rates change, discounts come and go, and each person's mix of input and output tokens differs. Plug official current prices into your own usage numbers instead.

Does the free endpoint on this site report token usage?

Each request leaves a technical log on the server, including token counts, and OpenAI-style responses include a usage object you can read on your side. The daily allowance is 10,000 requests or 10 million tokens per IP.

Why multi-provider spending gets murky

The typical path to confusion looks like this. A project starts with one provider. Someone adds a second model for a task it does better, then a cheaper one for bulk work, then a local runner for development. Each has its own console, invoicing cycle and units. By the end of the month, nobody can say which feature cost what.

Rapid change makes it worse. When providers ship flagship models within hours of each other, both claiming leads on different benchmarks, teams switch models more often, and every switch changes the cost profile. A spreadsheet updated once a month cannot keep up.

There is also a human factor. Engineers who cannot see the cost of their choices make different decisions from those who can. When a developer learns that a verbose system prompt adds a noticeable sum every month, it gets trimmed the same afternoon. Visibility changes behaviour more reliably than any policy document.

Invoices arrive too late

A monthly invoice tells you what happened weeks ago. A runaway loop or a prompt that suddenly doubled in size needs to be caught within hours.

Totals hide the cause

Knowing that you spent more this month is not actionable. Knowing that the summarisation feature for one large customer tripled its output tokens is.

Measure at the call site

The most reliable source of truth is your own code. Every time it calls a model, it knows the provider, the model name, the feature that made the call, and, from the response, how many tokens went in and out. Writing those facts to a log line takes microseconds and gives you a complete record that no dashboard can match.

Wrap your model calls in a small helper so the logging happens in one place. The example below appends one JSON line per request to a file; in production you would send it to whatever log or metrics system you already use.

Label every call with a feature

The feature field is what turns raw usage into decisions. Use stable names like search-summary or support-reply, and add a customer or project label if you bill clients.

import json
import time

from openai import OpenAI

free = OpenAI(base_url="https://api.anthropickeyfreeapi.com/v1", api_key="none")


def tracked_chat(client, provider, model, feature, messages, **kw):
    t0 = time.time()
    r = client.chat.completions.create(model=model, messages=messages, **kw)
    u = r.usage
    record = {
        "ts": round(t0),
        "provider": provider,
        "model": model,
        "feature": feature,
        "in": u.prompt_tokens if u else None,
        "out": u.completion_tokens if u else None,
        "secs": round(time.time() - t0, 2),
    }
    with open("usage.jsonl", "a") as f:
        f.write(json.dumps(record) + "\n")
    return r


r = tracked_chat(free, "free", "free-ai", "tagging",
                 [{"role": "user", "content": "Give three tags for: solar panel cleaning robot"}])
print(r.choices[0].message.content)
Meter attached to a cable powering a computer
Measure usage where the call happens.

Turning tokens into money

With usage recorded, cost is a lookup. Maintain a small price table keyed by provider and model, with separate rates for input and output tokens per million. Fill it from each provider's official pricing page, note the date you copied the numbers and review it whenever a provider announces changes.

Keep prices out of the log itself. If you store only token counts, you can recompute historical costs whenever rates change or when you want to ask what last month would have cost on another model.

Watch for special pricing rules

Some providers price cached input, batch requests or long contexts differently. If you use those features, add the relevant fields to your log so the calculation stays accurate.

import json
from collections import defaultdict

# USD per million tokens: copy current values from each provider's pricing page
PRICES = {
    ("free", "free-ai"): (0.0, 0.0),
    # ("provider", "model-name"): (input_rate, output_rate),
}

totals = defaultdict(float)
with open("usage.jsonl") as f:
    for line in f:
        r = json.loads(line)
        rate_in, rate_out = PRICES.get((r["provider"], r["model"]), (0.0, 0.0))
        cost = ((r["in"] or 0) * rate_in + (r["out"] or 0) * rate_out) / 1_000_000
        totals[r["feature"]] += cost

for feature, usd in sorted(totals.items(), key=lambda kv: -kv[1]):
    print(f"{feature:20s} ${usd:,.4f}")

Counting free and local models too

It is tempting to leave zero-cost back ends out of the ledger. Do not. Logging them shows how much work they absorb, which is exactly the number you need to judge whether they are worth keeping and what it would cost if they disappeared.

If ten thousand classification calls a day go to a free model, the log tells you what those calls would cost on a paid model. That is your real saving, and the figure to watch if you ever have to fall back. For the free endpoint on this site, remember the daily ceiling per IP of 10,000 requests or 10,000,000 tokens, reset at 00:00 UTC.

Local hardware has a cost, just not per token

For a local runner, you can estimate electricity and hardware depreciation per month and divide it by the tokens processed. The result is rough but makes comparisons fairer.

Jar of coins beside a stack of receipts
Store token counts and compute cost from a price table.

Budgets and alerts that actually fire

A ledger is only useful if someone looks at it, and nobody looks at it every day. Automate the looking. A scheduled job that sums yesterday's cost per feature and compares it with a rolling average can send a message when anything jumps by more than a set percentage.

On the provider side, set spending limits in each console. They act as a hard stop if your own alerts fail. Use both: your alerts for early warning and nuance, the provider's limits as the final guard.

Alert fatigue is real

Start with a small number of alerts that you would actually act on. If a warning fires every day and nobody reacts, raise its threshold or remove it until the remaining alerts are trusted.

Route alerts to the owners

Send each feature's cost alert to the team that owns the feature. A shared channel full of anonymous warnings tends to be ignored by everyone.

  • Daily summary per feature and per provider
  • Alert when a feature exceeds twice its seven-day average
  • Alert when average output tokens per call rise sharply
  • Hard monthly limits configured in every paid console
  • Weekly review of the top five most expensive features

Comparing providers fairly

When a new model launches, the headline price per million tokens is only half the story. A model that is cheaper per token but twice as verbose costs the same. A model that needs fewer retries or shorter prompts to get the right answer may be cheaper overall even at a higher rate.

Your usage log makes fair comparisons possible. Run the same batch of real tasks through two models, log both, and compare total cost per successful task, not per token. Combine that with a quality check from your evaluation set, as described in planning for model retirement.

Cost per task is the honest metric

Divide total spend by the number of tasks that produced an acceptable result. It folds in verbosity, retries and failures, which per-token prices ignore.

Quality is part of the price

Where a commercial model gives clearly better results, the extra cost may be worth it. A cheaper model that forces manual corrections is not actually cheaper.

Ceiling smoke detector with a glowing light
Alerts catch a runaway feature within hours.

Where the money usually goes

When teams first build a ledger, the findings tend to rhyme. A few features account for most of the spend. Output tokens cost more than expected because prompts never asked for brevity. Agents and long conversations dominate, because they resend context on every step. These patterns are worth checking in your own data first.

The fixes are mostly unglamorous: ask for shorter answers, trim context, cache what can be cached and route easy tasks to cheaper models. See why coding agents burn so many tokens for the agent-specific version of this story.

Long prompts hide in templates

A system prompt assembled from several templates can quietly grow over months. Logging input token counts per feature makes that growth visible long before it shows up on an invoice.

Keeping the ledger private and safe

A usage log contains no prompt text if you design it that way, which makes it much safer to keep and share than full request logs. Still, labels such as customer names can be sensitive. Use internal identifiers where possible and restrict access to people who need cost data.

Never log API keys, even partially. If a helper library logs request headers by default, turn that off. The ledger should tell you what was spent, not give anyone the means to spend more.

Remember the provider logs too

Every hosted API keeps its own records. This site, for instance, keeps a technical log per request with time, IP, User-Agent, country, endpoint, status, latency, sizes and tokens, but no account history.

Balance scale weighing coins against documents
Cost per successful task is the fair comparison.

Starting small this week

You do not need a full observability platform to begin. Add the wrapper around your model calls, write one JSON line per request and run the summary script once a day. After a week you will know more about your AI costs than any combination of vendor dashboards could tell you.

From there, add alerts, refine labels and connect the price table to your planning. When someone proposes a new model or a new feature, you can estimate its cost from real numbers rather than hope.

Once the basics run reliably, consider sharing a short monthly summary with the wider team: total spend, the most expensive features and one or two changes that saved money. It keeps costs on everyone's radar without turning them into a source of anxiety.

Try the free API

Send a prompt to the keyless free-ai endpoint from the home page and see how it handles your own task, no signup needed.

Read also