@pylva/sdk. It auto-instruments supported provider clients and emits server-priced telemetry to Pylva.
Initialize
endpoint for self-hosted deployments. Omit it for Pylva Cloud.
Auto-instrumentation
Importing the SDK patches supported provider clients in the host process. Current coverage:- OpenAI.
- Anthropic.
- Vercel AI.
customer_id, and step_name when a tracking context is active.
Tracking context
track uses async context so metadata follows nested awaits without manual argument threading.
LangGraph and LangChain callbacks
Use the callback entrypoint when LangGraph.js or LangChain.js owns the model calls. This path is observer-only and does not import the root SDK entrypoint, so it does not auto-patch providers.@pylva/sdk/langchain re-exports the same handler. Pylva records run ids,
parent run ids, graph node attribution, provider, model, token usage, latency,
status, and customer id. It does not send prompts, completions, tool inputs, or
tool outputs.
Customer id resolution order is:
- Constructor
customerId. metadata.pylva_customer_id.metadata.customer_id.- Active
track()context. anonymous.
metric="calls" and metric_value=1.
Non-LLM usage
Budget hard stops
Webhook verification
sha256= prefixed signatures.