Python
customer_id, and
step_name. It does not send prompts, completions, tool arguments, or tool
outputs.
TypeScript
@pylva/sdk/langchain re-exports the same TypeScript handler for LangChain.js
callback discoverability. The deep entrypoints do not import the root SDK, so
they do not auto-patch provider clients.
Node Attribution
LangGraph adds run metadata such aslanggraph_node. Pylva uses that as the
event step_name, so costs naturally group by graph node.
metadata["langgraph_node"]metadata["pylva_step"]metadata["langgraph_step"]- LangChain run name
PylvaCallbackHandler(customer_id="...")new PylvaCallbackHandler({ customerId: "..." })in TypeScriptmetadata["pylva_customer_id"]metadata["customer_id"]- Active
pylva.track_context - Active
track()context in TypeScript anonymous
Per-Customer Billing
Pass one stable opaque customer id per graph invocation.Tool Calls
Tool-call billing is opt-in because many tools are not billable. Enable it only when a tool execution itself should create a configured usage event.metric="calls" and metric_value=1. Configure the price
for that metric in Pylva before using it for invoices.
Avoid Double Counting
Use either the LangGraph callback path or the provider auto-instrumentation path for the same runtime. In TypeScript, importing@pylva/sdk/langgraph or
@pylva/sdk/langchain alone does not auto-patch providers; importing the root
@pylva/sdk package does.
Failure Behavior
Callback errors are swallowed. If Pylva is unavailable, the graph continues. When LangChain does not provide token usage, Pylva records the run with zero tokens andmetadata.usage_missing=true rather than reading prompt text to
estimate usage.