Get started with AgentOps in minutes with just 2 lines of code for basic monitoring, and explore powerful decorators for custom tracing.
AgentOps is designed for easy integration into your AI agent projects, providing powerful observability with minimal setup. This guide will get you started quickly.
First, install the AgentOps SDK. We recommend including python-dotenv
for easy API key management.
At its simplest, AgentOps can start monitoring your supported LLM and agent framework calls with just two lines of Python code.
import agentops
to your script.agentops.init()
with your API key.You need an AgentOps API key to send data to your dashboard.
It’s best practice to set your API key as an environment variable.
If you use a .env
file, make sure load_dotenv()
is called before agentops.init()
.
After adding the two lines and ensuring your API key is set up:
While AgentOps automatically instruments many popular libraries, you can gain finer-grained control and track custom parts of your code using our powerful decorators. This allows you to define specific operations, group logic under named agents, track tool usage with costs, and create custom traces.
@operation
Instrument any function in your code to create spans that track its execution, parameters, and return values. These operations will appear in your session visualization alongside LLM calls.
@agent
If you structure your system with specific named agents (e.g., classes), use the @agent
decorator on the class and @operation
on its methods to group all downstream operations under that agent’s context.
@tool
Track the usage of specific tools or functions, and optionally associate costs with them. This data will be aggregated in your dashboard.
@trace
or manual)Create custom traces to group a sequence of operations or define logical units of work. You can use the @trace
decorator or manage traces manually for more complex scenarios.
auto_start_session=False
in agentops.init()
, you must use @trace
or agentops.start_trace()
for any data to be recorded.You can also update metadata on running traces to add context or track progress:
Here’s a consolidated example showcasing how these decorators can work together:
You’ve seen how to get started with AgentOps! Explore further to leverage its full potential:
See how AgentOps automatically instruments popular LLM and agent frameworks.
Explore detailed examples for various use cases and integrations.
Dive deeper into the AgentOps SDK capabilities and API.
Learn how to group operations and create custom traces using the @trace decorator.
Get started with AgentOps in minutes with just 2 lines of code for basic monitoring, and explore powerful decorators for custom tracing.
AgentOps is designed for easy integration into your AI agent projects, providing powerful observability with minimal setup. This guide will get you started quickly.
First, install the AgentOps SDK. We recommend including python-dotenv
for easy API key management.
At its simplest, AgentOps can start monitoring your supported LLM and agent framework calls with just two lines of Python code.
import agentops
to your script.agentops.init()
with your API key.You need an AgentOps API key to send data to your dashboard.
It’s best practice to set your API key as an environment variable.
If you use a .env
file, make sure load_dotenv()
is called before agentops.init()
.
After adding the two lines and ensuring your API key is set up:
While AgentOps automatically instruments many popular libraries, you can gain finer-grained control and track custom parts of your code using our powerful decorators. This allows you to define specific operations, group logic under named agents, track tool usage with costs, and create custom traces.
@operation
Instrument any function in your code to create spans that track its execution, parameters, and return values. These operations will appear in your session visualization alongside LLM calls.
@agent
If you structure your system with specific named agents (e.g., classes), use the @agent
decorator on the class and @operation
on its methods to group all downstream operations under that agent’s context.
@tool
Track the usage of specific tools or functions, and optionally associate costs with them. This data will be aggregated in your dashboard.
@trace
or manual)Create custom traces to group a sequence of operations or define logical units of work. You can use the @trace
decorator or manage traces manually for more complex scenarios.
auto_start_session=False
in agentops.init()
, you must use @trace
or agentops.start_trace()
for any data to be recorded.You can also update metadata on running traces to add context or track progress:
Here’s a consolidated example showcasing how these decorators can work together:
You’ve seen how to get started with AgentOps! Explore further to leverage its full potential:
See how AgentOps automatically instruments popular LLM and agent frameworks.
Explore detailed examples for various use cases and integrations.
Dive deeper into the AgentOps SDK capabilities and API.
Learn how to group operations and create custom traces using the @trace decorator.