Python SDK — LangChain Integration
Python SDK — LangChain Integration
The recommended way to track LangChain pipelines in production is using the explicit PaygentLangChainCallback. This approach provides fine-grained control over tracking context and enables seamless multi-model pipeline monitoring.
Production Callback Integration
Attach the PaygentLangChainCallback to your model instances to automatically track tokens, costs, and performance across every step of your chain.
langchain_production.py
Why use callbacks?
- Named Context: Group different parts of your application under distinct indicators.
- Auto-Onboarding: Automatically create customers in Paygent when they first interact with your AI.
- Multi-Model: Track usage across OpenAI, Anthropic, Gemini, and Mistral in a single unified view.
Multi-Model Pipeline Example
Complex workflows often involve multiple LLM providers. By passing the same callback instance to every model, you maintain a consistent billing context.
multi_model_pipeline.py
