Your agents work all night.Someone should keep watch.
End-to-end observability for AI agents. Trace every run down to the line of code, replay what happened, and test the fix on real runs. On your own machines, with no proxy in the way.
- No proxy: calls go straight to your provider
- Self-hosted with one command
- 45+ providers, 15+ agent frameworks
Two lines in your app.
No proxy in between.
Or no code at all: start your app with NODE_OPTIONS=--import costkey/register. npx costkey setup creates a project and writes the DSN for you.
In our loopback benchmark, watching a call added 0.008 ms at p50 in TypeScript and 0.14 ms in Python. Run it yourself →
npm install costkeyimport { CostKey } from "costkey";
CostKey.init(); // reads COSTKEY_DSNpip install costkeyimport costkey
costkey.init() # reads COSTKEY_DSNSee every run.
Every step, timed and priced.
Every model call, tool and handoff on one timeline
Open any run and see each step in order, with how long it took and what it cost.
Failures and latency by model
See which model fails, retries or slows down the most.
| Model | Failed | p95 | Wasted |
|---|---|---|---|
| 0.6% | 6.4 s | $1.88 | |
| 0.1% | 4.1 s | $0.96 | |
| 0% | 1.2 s | $0.04 | |
| 0% | 3.0 s | $0.00 | |
| 0% | 1.1 s | $0.00 | |
| 0.2% | 1.9 s | $0.21 | |
| 0% | 2.2 s | $0.02 |
Alerts in Slack, email or a webhook
Spikes, budget warnings and refused calls reach your team in minutes.
Find what broke.
Replay it, then jump to the code.
Replay what your browser agent did
Watch the run like a video and see the moment it went wrong.
node --import @costkey/replay/register agent.jsAgent actions
Add to cartgpt-5 · 0:09Checkoutgpt-5 · 0:19Email18 characters, text not kept#payA popup took the clickThe line of code behind every call
Go from a slow or failed call straight to the code that made it.
crawlAndSummarizesrc/agents/research.ts:87researchAgent.runsrc/agents/research.ts:41POST /api/researchsrc/routes/research.ts:18queue.processsrc/worker.ts:12Let your coding agent read your runs
Claude Code, Cursor, Codex and VS Code can ask CostKey what failed and why, over MCP. Read-only.
Check the answers. Test the fix.
Score every run. Try a new model.
Quality scores on every run
Know whether the answer was any good, and why it got that score.
search_web for an order status that lookup_order returns directly.Your own checks and rules
Ask your own yes or no question of every run, or set simple limits.
Label real runs into datasets
Save the good and bad moments from real runs as test cases.
Test a new model or prompt on real runs
Try a cheaper model on those cases before you switch. Runs in your own code, from the TypeScript SDK.
Keep spend in check.
Budgets, a kill switch, a forecast.
Budgets for any agent, customer or model
Set a limit and hear about it at 80%, before the bill surprises you.
A kill switch that stops runaway runs
When an agent loops, the next call is refused before you pay for it.
Spend by customer or feature
Know what each customer or feature costs you to serve.
A forecast of month-end spend
See where this month's bill is heading, and what 10 times the users would cost.
Cumulative spend
ActualEstimatedBuilt for the whole team.
Dashboards, roles and summaries.
Build your own dashboards
Put the numbers your team checks every day on one page.
Calls over time
Each day, all agentsCalls by feature
BreakdownSpend by customer
BreakdownPrompts stay private by default
Prompts and responses are not stored unless you turn that on.
Roles for every teammate
Developers see prompts and code. Finance sees only costs.
| Owner | Everything, with billing |
| Admin | Everything, and the team |
| Developer | Costs, prompts and code |
| Viewer | Costs |
Daily and weekly summaries
A short report by email or Slack, so nobody has to open the console.
Daily spend · 19 Oct
$281.40 yesterday, 12% more than the day before.
- Top features support-agent, research-agent, summarize
- Top models claude-sonnet-4-5, gpt-5, gemini-2.5-flash
- Budgets Support monthly is at 82%
Secrets stay in your app
API keys, tokens and JWTs are replaced with [REDACTED] before anything is sent.
Single sign-on
Google Workspace, Okta or Microsoft Entra ID, through OpenID Connect.
Sourcemaps
Minified stack traces read as your original source.
Compare two deploys
See what a release changed in speed, failures and cost.
Next to Sentry or Datadog
Runs alongside the monitoring tools you already have.
OpenTelemetry
Anything that emits OpenTelemetry spans shows up as a run.
Your own prices
Set negotiated rates, and prices for models you host yourself.
Deploy anywhere
Kubernetes, Fly, Render, Railway, Cloud Run or AWS.
Self-host
Run it yourself. One command.
Postgres and one container, on your machines. Your data never leaves them.
curl -fsSL https://costkey.dev/install.sh | shWhat is CostKey?
CostKey is end-to-end observability for AI agents and workflows. It traces every run, model call and tool across 45+ providers, down to the line of code. It replays what browser agents did, scores quality, runs evals on real runs, and tracks cost with budgets, Slack alerts and a kill switch. It runs on your own machines.
How much does CostKey cost?
Nothing. CostKey runs on your own machines. Talk to us if you want help setting it up.
Which agent frameworks does CostKey work with?
The OpenAI Agents SDK, Vercel AI SDK, Mastra, LangChain and LangGraph, CrewAI, LlamaIndex, Pydantic AI, Google ADK, the Claude Agent SDK, smolagents, AutoGen, AG2, DSPy, Strands and browser-use, each with a one-line integration in TypeScript or Python. Anything that emits OpenTelemetry spans works through the OpenTelemetry bridge, and model calls are captured whatever framework makes them.
Does CostKey sit between my app and my providers?
No. The SDK watches the calls your app already makes and reports them in the background. Requests go straight to your providers, with your keys.
How do I run CostKey?
On your own machines. curl -fsSL https://costkey.dev/install.sh | sh starts Postgres and the CostKey server and console with Docker. Open localhost:4100, sign up, and copy your project's DSN into your app.
How do I see one agent run as one trace?
Wrap the agent with CostKey.agent and its tools with CostKey.tool (costkey.agent and costkey.tool in Python). Every model call inside lands on that run's timeline with its cost and duration.
Can I watch what my browser agent did?
Yes. Add @costkey/replay and every page your Playwright or Puppeteer agent drives is recorded and played back like a video, next to the model call behind each action. Typed text is masked, and nothing is recorded until an admin turns on screen recordings for the project.
Where do evals run?
In your own environment, with your own keys. Label calls into a dataset in the console, then CostKey.runEval in the TypeScript SDK replays them against the model or prompt you choose. The console shows the pass rate and the cost next to the original calls.
How does the kill switch work?
Turn on enforcement in the SDK and set a budget to stop new calls. Before each call, CostKey checks the worst-case cost against the budget and refuses the call before it reaches the provider. Calls already running finish. Supported for 14 major model providers today.
What counts as a failed run?
A run fails when it errors, a model call fails without a successful retry, or a tool or step fails. CostKey shows what each failure cost.
Do you store my prompts?
Not by default. New projects keep cost, usage, timing and source only. Prompt storage is a per-project switch, and you choose how long to keep it. Either way it stays in your own database.