1

Install the AgentOps SDK

2

Add 2 lines of code

Make sure to call agentops.init before calling any openai, cohere, crew, etc models.

Get an AgentOps API key here

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

3

Run your agent

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

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

Clickable link to session

Give us a star if you liked AgentOps! (you may be our 3,000th 😊)

More basic functionality

Decorate Functions

You can instrument other functions inside your code with the handy @record_action decorator, which will record an action_type, the parameters, and the returns. You will see these function calls alongside your LLM calls from instantiating the AgentOps client.

python
# (record specific functions)
@agentops.record_action('sample function being recorded')
def sample_function(...):
  ...

Track Agents

If you use specific named agents within your system, you can tie all downstream Events to a Named Agent with the @track_agent decorator.

python
# (track a named agent)
@agentops.track_agent(name='my-expert-agent')
class sample_agent(...):
  ...

Ending Your Session

Finally, you should end your session by calling .end_session() indicating whether your session was successful or not (Success|Fail). We suggest setting session state depending on how your agent exits or whether your agent succeeded or not. You can also specify a end state reason, such as user interrupted, ran to completion, or unhandled exception.

python
# End of program
agentops.end_session('Success')

Example Code

Here is the complete code from the sections above

python
import openai
import agentops

# Beginning of program (i.e. main.py, __init__.py)
agentops.init(<INSERT YOUR API KEY HERE>)

# (record specific functions)
@agentops.record_action('sample function being record')
def sample_function(...):
  ...

# (track a named agent)
@agentops.track_agent(name='my-expert-agent')
class sample_agent(...):
  ...

# End of program
agentops.end_session('Success')

Simple Code Example

Jupyter Notebook with sample code that you can run!

That’s all you need to get started! Check out the documentation below to see how you can record other events. AgentOps is a lot more powerful this way!

Explore our more advanced functionality!