Recording Operations
Track operations and LLM calls in your agent applications.
AgentOps makes it easy to track operations and interactions in your AI applications with minimal setup.
Basic Setup
The simplest way to get started with AgentOps is to initialize it at the beginning of your application:
That’s it! This single line of code will:
- Automatically create a session for tracking your application run
- Intercept and track all LLM calls to supported providers (OpenAI, Anthropic, etc.)
- Record relevant metrics such as token counts, costs, and response times
Automatic Instrumentation
AgentOps automatically instruments calls to popular LLM providers without requiring any additional code:
This works with many popular LLM providers including:
- OpenAI
- Anthropic
- Google (Gemini)
- Cohere
- And more
Advanced: Using Decorators for Detailed Instrumentation
For more detailed tracking, AgentOps provides decorators that allow you to explicitly instrument your code. This is optional but can provide more context in the dashboard.
@operation
Decorator
The @operation
decorator helps track specific operations in your application:
@agent
Decorator
If you use agent classes, you can track them with the @agent
decorator:
Advanced Session Management
If you need more control over session lifecycle, you can disable automatic session creation:
Best Practices
-
Keep it Simple: For most applications, just initializing AgentOps with
agentops.init()
is sufficient. -
Use Decorators Sparingly: Only add decorators when you need more detailed tracking of specific operations.
-
Meaningful Operation Names: When using decorators, choose descriptive names to make them easier to identify in the dashboard.