THROUGHPUTS

Cost Estimation

Predict spend before you ship, and track it after.

THROUGHPUTS gives you the tools to estimate cost before you run a single request, and to track spend on every response after you ship.

Before: estimate a workload

Use POST /v1/pricing/estimate to predict monthly cost for a workload:

curl https://api.throughputs.dev/v1/pricing/estimate \
  -H "Authorization: Bearer $THROUGHPUTS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "monthlyInputTokens": 2000000,
    "monthlyOutputTokens": 500000
  }'
{
  plan: "pay-as-you-go",
  monthlyCostUsd: 9.6,
  perMillionIn: 2.4,
  perMillionOut: 9.6,
  breakEvenPlan: "bundle",
  breakEvenSavingsUsd: 1.92
}

The response tells you which plan minimizes cost at your volume. Use it to decide between pay-as-you-go and a committed plan.

After: per-response headers

Every chat completion response includes cost headers:

HeaderDescription
X-Throughputs-Tokens-InPrompt tokens billed.
X-Throughputs-Tokens-OutCompletion tokens billed.
X-Throughputs-Cost-UsdCost of this request in USD (6 decimals).
X-Throughputs-ModelThe model that actually served (may differ after failover).

Log these to your observability stack to attribute spend per user, feature, or tenant.

const client = new Throughputs({ apiKey });

const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [...],
});

// First-party SDK exposes cost directly:
console.log(response.throughputsCostUsd); // 0.002431
console.log(response.throughputsModelServed); // "gpt-4o"

Aggregating spend

Use the first-party SDK's spend tracker to accumulate cost across many calls in a session or job:

from throughputs import Throughputs

client = Throughputs(api_key="thp_live_xxx")

with client.spend_tracker() as tracker:
    for msg in conversation:
        response = client.chat.completions.create(
            model="gpt-4o",
            messages=msg,
        )
    print(tracker.total_usd)       # sum of all requests in this block
    print(tracker.total_tokens_in) # sum of input tokens
    print(tracker.total_tokens_out) # sum of output tokens

Break-even math

At what volume does a committed plan beat pay-as-you-go?

For the Bundle plan ($99/mo, 20% off per-token):

break_even_tokens = 99 / (list_price_per_token * 0.20)

For gpt-4o at $2.40 / 1M in + $9.60 / 1M out, assuming a 4:1 input-to-output ratio:

avg_price_per_token = (2.40 * 4 + 9.60 * 1) / (4 + 1) / 1_000_000
break_even_tokens   = 99 / (avg_price_per_token * 0.20)
                    ≈ 20.6M tokens / month

Past ~20M tokens/month on gpt-4o, Bundle wins. The pricing calculator computes this for your actual mix automatically.

Cost-aware model routing

For chat UIs where latency matters less than cost, route to the cheapest model that meets a quality bar:

def pick_model(max_cost_per_million: float, must_support_vision: bool):
    models = client.models.list()
    candidates = [
        m for m in models.data
        if m.pricing.inputPerMillion <= max_cost_per_million
        and (not must_support_vision or "vision" in m.capabilities)
    ]
    candidates.sort(key=lambda m: m.pricing.inputPerMillion)
    return candidates[0].id if candidates else "gpt-4o-mini"

Budget enforcement

Pass spendLimitUsd when creating a key to cap lifetime spend. When the key hits its cap, requests return 402 Payment Required:

curl https://api.throughputs.dev/v1/keys \
  -H "Authorization: Bearer $THROUGHPUTS_ADMIN_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "staging-backend",
    "scope": "completions-only",
    "spendLimitUsd": 50
  }'

Update the cap with PATCH /v1/keys/{id} if you need to raise it.

On this page