cd /news/ai-tools/show-hn-marginal-see-which-customers… · home topics ai-tools article
[ARTICLE · art-102986] src=marginalhq.com ↗ pub= topic=ai-tools verified=true sentiment=· neutral

Show HN: Marginal – See which customers and features drive your AI API costs

Marginal, a new cost-observability tool for AI API usage, launched with TypeScript and Python SDKs plus an HTTP API, enabling developers to track the cost of every LLM call and slice spend by customer, feature, or model. The tool computes costs server-side against a daily-synced price catalog, flags unpriced models instead of averaging them away, and integrates via a single track() call per request. Marginal aims to answer 'why was the bill that high?' by automatically charting spend across dimensions and logging every API request outcome.

read3 min views3 publishedAug 19, 2026

TypeScript SDK · Python SDK · HTTP API

Marginal tracks the cost of every LLM call and slices it by the fields you care about — customer, feature, model.

npm install marginal-sdk · pip install marginal-sdk

The dashboard

From “the bill doubled” to a named cause #

Slice spend by what matters in your product, see every dimension charted automatically, and check exactly what your integration sent.

Spot the spike without building a chart

Insights charts spend for every dimension automatically — each model, provider, and registered field gets its own chart. No setup, no query builder.

Know exactly what landed

Every API request is logged with its outcome — accepted counts, rejected events and why, stripped keys, unpriced models. Debug your integration without guessing.

Never a silent $0

Unknown model? The event still lands, flagged as unpriced — visible in the dashboard and the API response, never averaged away. Set a custom price and it applies at ingest.

How it works

One call per LLM request. That's the whole integration. #

  • 1

Pick your connection

npm install marginal-sdk

,pip install marginal-sdk

, or no install at all — POST JSON to the HTTP API from any language. The SDKs are zero-dependency, buffered, fire-and-forget: track() never throws and never blocks your request path. - 2

Track each LLM call

Name the provider, paste the response's

model

andusage

as-is — Marginal detects the usage shape and computes the cost server-side against a daily-synced model price catalog. - 3

Slice your spend

Group and filter by customer, feature, model — any field you register. Save the views you keep coming back to.

import { Marginal } from "marginal-sdk";

const marginal = new Marginal({ apiKey: process.env.MARGINAL_API_KEY });

const response = await openai.chat.completions.create({ /* … */ });

marginal.track({
  provider: "openai",
  model: response.model,
  usage: response.usage,
  fields: { customer: "acme-corp", feature: "support-bot" },
});
python
import os

from marginal import Marginal

marginal = Marginal(api_key=os.environ["MARGINAL_API_KEY"])

response = client.chat.completions.create(...)

marginal.track(
    provider="openai",
    model=response.model,
    usage=response.usage.model_dump(),
    fields={"customer": "acme-corp", "feature": "support-bot"},
)
curl -X POST https://api.marginalhq.com/v1/events \
  -H "Authorization: Bearer $MARGINAL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [
      { "provider": "openai",
        "model": "gpt-4o-2024-08-06",
        "usage": { "prompt_tokens": 2006, "completion_tokens": 300 },
        "fields": { "customer": "acme-corp", "feature": "support-bot" } }
    ]
  }'

The cost lands computed, priced at that day's catalog rates — no token math in your codebase.

Cost observability

Built to answer “why was the bill that high?” #

Slice by any field

Register your vocabulary — customer, feature, anything you slice by — then group or filter spend by it. Unregistered keys are stripped and reported back, so dashboards stay clean.

LLM-aware pricing

Send provider, model, and the response's usage object; cost is computed server-side from a daily-synced price catalog, with per-project overrides. Prices are frozen at ingest.

Saved views

Any Explorer state — range, filters, group-by — saves as a named view. The questions you ask every week are one click away.

SDKs that stay out of the way

TypeScript and Python, zero dependencies. Events buffer locally and flush in batches in the background; network failures retry and then warn — your app never notices. Prefer no SDK? The HTTP API is a single JSON POST.

Let your coding agent do the integration #

Paste marginalhq.com/llms.txt into Claude Code, Cursor, or any coding assistant and it has everything it needs to wire up Marginal — or follow the per-provider recipes yourself.

Integration recipes

From zero to a live spend dashboard in five minutes. #

Create a project, register your fields, drop in one track() call. Your next deploy starts answering questions.

── more in #ai-tools 4 stories · sorted by recency
── more on @marginal 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
Live at https://your-agent.zahid.host
Get free account → Pricing
from €0/mo · no card required
LIVE [news/show-hn-marginal-see…] indexed:0 read:3min 2026-08-19 ·