CostKey
NewBrowser replay, datasets, evals and dashboards

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
costkey.yourcompany.com
OpenAIAnthropicGeminiAWS BedrockAzure OpenAIMistralDeepSeekxAIGroqTogether AIFireworksOpenRouterCoherePerplexityDeepgramElevenLabsAssemblyAITavilyExaFirecrawlHugging FaceOllama
OpenAI Agents SDKLangChainLangGraphVercel AI SDKMastraCrewAILlamaIndexPydantic AIGoogle ADKClaude Agent SDKsmolagentsAutoGenAG2DSPyStrands Agentsbrowser-useOpenTelemetry
Every integration, with setup, in the docs →

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 →

TypeScriptnpm install costkey
import { CostKey } from "costkey";
CostKey.init(); // reads COSTKEY_DSN
Pythonpip install costkey
import costkey
costkey.init()  # reads COSTKEY_DSN

See 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.

voice-supportRun 4b1a · 6 calls · 6 providers
Whole run$0.04326.8 s
0 s2 s4 s6 s
Deepgramtranscribenova-3 · 192 s audio1.1 s$0.0041
OpenAIembedQuerytext-embedding-3-small · 1,240 tokens0.2 s$0.0001
TavilylookupPolicysearch · 1 query0.9 s$0.0080
AnthropicdraftReplyclaude-sonnet-4-5 · 4,180 tokens2.4 s$0.0123
GeminigradeReplygemini-2.5-flash · 2,050 tokens0.6 s$0.0004
ElevenLabsspeakeleven_v3 · 1,840 characters1.6 s$0.0183
Deepgram 9%OpenAI 0%Tavily 19%Anthropic 28%Gemini 1%ElevenLabs 42%

Failures and latency by model

See which model fails, retries or slows down the most.

ModelCallsFailedErrorsRetriesp95Wasted
gpt-56,9400.6%429, 500316.4 s$1.88
claude-sonnet-4-518,2040.1%52984.1 s$0.96
gemini-2.5-flash41,3000%—21.2 s$0.04
deepseek-chat7,1000%—03.0 s$0.00
nova-32,3300%—11.1 s$0.00
claude-haiku-4-512,4800.2%52961.9 s$0.21
gpt-5-mini9,3200%—32.2 s$0.02

Alerts in Slack, email or a webhook

Spikes, budget warnings and refused calls reach your team in minutes.

# agent-alerts
CostKey APP · 09:14
Latency spike in summarize
18.4 s a call, 6× its 7-day average.
CostKey APP · 14:02
Budget at 80%
Support monthly: $656.00 of $800.00.
CostKey APP · 02:14
A call was refused
browser-agent hit its daily budget.

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.js

The line of code behind every call

Go from a slow or failed call straight to the code that made it.

ContentCost & usageSource
crawlAndSummarizesrc/agents/research.ts:87
gpt-5 · 8,904 in / 1,210 out · 6.1 s · $0.0232
researchAgent.runsrc/agents/research.ts:41
POST /api/researchsrc/routes/research.ts:18
queue.processsrc/worker.ts:12

Let 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.

Answered the question0.94
Faithfulness0.91
Safety0.99
Tool choice0.62
Why 0.62Called 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.

CheckDid the agent escalate when the customer asked for a human?
run 4b1a · support-agentNo
The customer asked twice for a person; the agent kept offering help articles.
Cost per run under $0.50Pass
Retries under 3Pass

Label real runs into datasets

Save the good and bad moments from real runs as test cases.

checkout clicks13 Good · 8 Bad
Northwind SupplyCart 0
Trail lanternAdd to cart
Field notebookAdd to cart
Subtotal $0.00Checkout
click Add to cartGoodBad
Northwind SupplyCart 1
Trail lanternAdded
Field notebookAdd to cart
Subtotal $48.00Checkout
click CheckoutGoodBad
Northwind SupplyCheckout
Email******************
Trail lantern$48.00
Pay $48.00
type into EmailGoodBad
Northwind SupplyCheckout
Email******************
Trail lantern$48.00
Pay $48.00
10% off your first orderGet my code
click #payGoodBad

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.

Eval runPass rateCost
claude-haiku-4-519 of 21 passed90%71% less
gpt-5-mini16 of 21 passed76%84% less
gemini-2.5-flash12 of 21 passed57%93% less
Case 14 · click CheckoutPass
Northwind SupplyCart 1
Trail lanternAdded
Field notebookAdd to cart
Subtotal $48.00Checkout
Original clickclaude-haiku-4-5, 12 px away
// Runs in your environment. CostKey never holds your provider keys. await CostKey.runEval({ dataset: "checkout clicks", task: (item) => anthropic.messages.create({ ...item.input, model: "claude-haiku-4-5" }), });

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.

support-agent, monthly$656.00 of $800.0082%
OpenAI $312Anthropic $214ElevenLabs $130
customer acme-corp, daily$2.05 of $5.00 today41%

A kill switch that stops runaway runs

When an agent loops, the next call is refused before you pay for it.

browser-agentcostkey · enforce
step 211 · retrying checkout page
step 212 · retrying checkout page
step 213 · retrying checkout page
CostKeyPolicyRefused: budget_exhausted
Refused before it reached the provider. Calls already running finish.

Spend by customer or feature

Know what each customer or feature costs you to serve.

CustomerFeatureFunctionModelProvider

A forecast of month-end spend

See where this month's bill is heading, and what 10 times the users would cost.

Cumulative spend

ActualEstimated
$0$250$500Day 1Day 10Day 20Day 31$400 budget$248.60 today~$412.90 by day 31
What would more users cost?Today's users$412.902x users$825.8010x users$4,129a month, at today's cost per user

Built for the whole team.
Dashboards, roles and summaries.

Build your own dashboards

Put the numbers your team checks every day on one page.

Agent overview5 widgets · last 7 daysEdit
Calls70,960
Tokens48.2M
Calls over time
Each day, all agents
10,137Daily average
MonTueWedThuFriSatSun
Calls by feature
Breakdown
70,960Total
support-agent31,22044%
research-agent19,87028%
summarize12,35017%
voice-intake7,52011%
Spend by customer
Breakdown
acme-corp$824.10
northwind$417.30
globex$341.00
+ Add widget
TotalOver timeBreakdown

Prompts stay private by default

Prompts and responses are not stored unless you turn that on.

Store prompts and responses
Cost and usage onlyDefault for new projects
Cost, usage and promptsKept for the days you choose

Roles for every teammate

Developers see prompts and code. Finance sees only costs.

OwnerEverything, with billing
AdminEverything, and the team
DeveloperCosts, prompts and code
ViewerCosts

Daily and weekly summaries

A short report by email or Slack, so nobody has to open the console.

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.

Terminal
$curl -fsSL https://costkey.dev/install.sh | sh
Wrote costkey/.env with new secrets. Keep it safe.
Starting CostKey....
CostKey is running at http://localhost:4100
Open it, sign up, and copy your project's DSN into your app.
Self-hosting guide → Read the code on GitHub →

Want a hand?

We'll help you set it up and get your first agent watched.

Before you
connect.

Something else? Ask us or read the docs.

What 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.

Leave a light on.

Get started Star on GitHub