costobs

open source · apache-2.0 · self-hosted

Know what every AI call costs.
Your data never leaves.

Per-request cost attribution for LLM & AI APIs — by customer, feature, team, prompt version, even merged PR. One line to integrate. Zero bytes phoned home.

docker compose up no proxy in your hot path no prompt content stored

01 / the differentiator

Offline by design

Every "AI cost tracking" SaaS asks you to ship usage — and often traffic — to their cloud. CostObs is built the other way around: the SDK computes cost locally from a bundled pricing file and ships metadata to your ClickHouse. Run it on a laptop or in an air-gapped cluster.

no phone home

No telemetry, no license checks

No mandatory cloud control plane, no account, no usage pings. The only outbound call in the whole system is the opt-in billing sync — and it's off by default.

no proxy

Never in your hot path

Your calls go straight to the provider. Cost calc happens after the response; shipping is async and batched. <1ms overhead, no new failure mode for production traffic.

no content

Prompts are never stored

The wire schema has no slot for prompt or response bodies — it can't leak what it can't carry. Token counts, latency, cost, and your attribution tags. That's it.

02 / how it works

One line in. Answers out.

step 01

Wrap your client

Python, TypeScript, or Go. The wrapper proxies every call straight through and tees usage off the response — including streams. xAI, Together, Groq, Mistral & friends are auto-detected through their OpenAI-compatible endpoints.

import costobs
from openai import OpenAI

client = costobs.wrap(OpenAI(), team="payments", environment="prod")

with costobs.request_context(customer_id="cust-42"):
    client.chat.completions.create(
        model="gpt-4o", messages=[...],
        feature="summarize", prompt_version="v3",
    )
import { wrap } from "@costobs/sdk";

const client = wrap(new OpenAI(), { team: "payments" });

await client.chat.completions.create({
  model: "gpt-4o", messages: [...],
  costobs: { feature: "summarize", customer_id: "cust-42" },
});
co := costobs.New(costobs.Config{Team: "payments"})
httpClient := &http.Client{Transport: co.Transport(nil)}
oai := openai.NewClient(option.WithHTTPClient(httpClient))

ctx = costobs.WithMetadata(ctx, costobs.Metadata{
    CustomerID: "cust-42", Feature: "summarize",
})
step 02

Cost is computed locally, shipped async

Exact decimal math from a versioned pricing file: per-token, cached tokens, reasoning, image tiles, audio-seconds, TTS characters. Events batch to your own ingest service and land in ClickHouse rollups built for sub-second queries at 10M+ events.

step 03

Ask the questions finance keeps asking you

What does customer X cost us? Which feature burns the budget? Did prompt v3 make things cheaper or just slower? What will month-end look like? Is our tracked spend matching the provider's actual bill — and if not, who's spending outside the SDK?

CostObs dashboard — dark console UI showing total spend, daily spend chart, provider donut and top models

03 / what's in the box

The whole cost loop, not just a counter

Per-request attribution

Customer, feature, team, service, environment, user, trace, prompt version — plus any custom tag.

Invoice reconciliation

Sync actual bills from provider admin APIs. See drift and untracked spend per provider, per day.

Seasonal forecasting

Holt-Winters weekly seasonality + linear & exponential fits with R². Month-end estimates that respect your weekend dip.

Prompt version A/B

Cost per request, output tokens, and p95 latency across versions of the same prompt, side by side.

Alerts that fire

Daily thresholds, spike detection, monthly budgets → Slack or any webhook, with cooldowns.

Every provider

OpenAI, Anthropic, Gemini, Bedrock, LiteLLM, Vercel AI SDK, every OpenAI-compatible API — and record() for the rest.

Cost per merged PR

Tag calls in CI with pr / engineer / experiment and slice spend by any tag. Engineering ROI as a query.

Built to self-host

Compose for a laptop, Helm for prod, BYO Postgres + ClickHouse. Prometheus metrics on every service.

04 / the honest comparison

CostObs vs. SaaS cost trackers

Same job. Different philosophy about who holds your data.

CapabilityCostObsTypical SaaS tracker
Per-request attribution (customer / feature / team / tag)
Invoice reconciliation & untracked spend
Spend forecasting✓ free, seasonalpaid tier
Prompt version A/B with p95 latency
Your data stays on your infra✓ always✕ their cloud
Works air-gapped
Open source, auditable wire schema✓ Apache-2.0
Price$0 + your hardware$30–$200+/mo

05 / start now

Dashboard in five minutes

git clone https://github.com/officialasishkumar/costobs
cd costobs
cp .env.example .env
docker compose up

# populated dashboard without a provider key:
make demo-data

That brings up

  1. ClickHouse + Postgres, migrated and seeded
  2. ingest :8080 — authenticated event intake
  3. alertd — thresholds, spikes, budgets
  4. billsyncd — opt-in invoice sync
  5. the console at localhost:3000

Read the docs →