Quickstart
Start using AgentOps with just 2 lines of code
Install the AgentOps SDK
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.
Run your agent
Execute your program and visit app.agentops.ai/drilldown to observe your Agent! 🕵️
Clickable link to session
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.
# (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.
# (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.
# End of program
agentops.end_session('Success')
Example Code
Here is the complete code from the sections above
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!