LangGraph observability and tracing
Trace LangGraph and LangChain runs node by node, see which step failed, and know what every run cost. On your own machines.
What you get
- Chains, graphs, graph nodes, agents, tools and retrievers become spans.
- Every model call priced, across 45+ providers, and attributed to the step it ran in.
- The function, file and line behind each call.
- Failed and retried runs, with the error and the step that raised it.
- Cost split by agent or tool, and budgets on either.
- Quality checks scored on every finished run.
- chainLangGraph$0.0412
- nodeplan0.8s
- llmclaude-sonnet-4-50.8s
- nodesearch1.6s
- toolweb_search1.1s
- retrieverdocs140ms
- nodewrite3.4s
1. Start CostKey
Run it on your own machines. Open http://localhost:4100, sign up and copy your project's DSN.
bash
curl -fsSL https://costkey.dev/install.sh | sh2. Install the SDK
bash · Python
pip install "costkey[langgraph]"bash · TypeScript
npm install costkeyPython
import os
import costkey
costkey.init(dsn=os.environ["COSTKEY_DSN"])TypeScript
import { CostKey } from 'costkey'
CostKey.init({ dsn: process.env.COSTKEY_DSN })3. Add the LangGraph integration
Python
from costkey.integrations.langchain import CostKeyCallbackHandler
result = graph.invoke(inputs, config={"callbacks": [CostKeyCallbackHandler()]})TypeScript
import { CostKeyCallbackHandler } from 'costkey/integrations/langchain'
const costkey = new CostKeyCallbackHandler()
await graph.invoke(input, { callbacks: [costkey] })The same handler works for LangChain chains and agents. Model calls are captured from HTTP, so nothing is counted twice.
Full reference: LangGraph in the docs.
Questions
Is this a LangSmith replacement?
For production tracing, failures and cost, yes. See CostKey vs LangSmith for what each covers.
Does it work with LangGraph Platform?
It works wherever your graph runs in your own process: the handler goes in the run config.
Try it on your own machines
One command starts Postgres, the server and the console with Docker.
bash
curl -fsSL https://costkey.dev/install.sh | sh