AgentOps works seamlessly with applications built using LangChain.

Adding AgentOps to LangChain applications

1

Install the AgentOps SDK and the additional LangChain dependency

Give us a star on GitHub while you’re at it (you may be our 2,000th 😊)
2

Set up your import statements

Import the following LangChain and AgentOps dependencies

3

Set up your LangChain handler to make the calls

Note that you don’t need to set up a separate agentops.init() call, as the LangChain callback handler will automatically initialize the AgentOps client for you.

Set up your LangChain agent with the AgentOps callback handler, and AgentOps will automatically record your LangChain sessions.

Set your API key as an .env variable for easy access.

Read more about environment variables in Advanced Configuration

4

Run your agent

Execute your program and visit app.agentops.ai/drilldown to observe your LangChain Agent! 🕵️

After your run, AgentOps prints a clickable URL to the console linking directly to your session in the Dashboard

Clickable link to session

Full Examples