AgentOps

0.4.21 · active · verified Sun Apr 12

AgentOps is an observability and DevTool platform for AI agents, providing tools to trace, debug, and deploy reliable AI agents and LLM applications. It offers features like session replays, LLM cost tracking, failure detection, tool usage statistics, and benchmarking, helping engineers move AI agents from prototype to production by ensuring they operate safely, efficiently, and transparently.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates the minimal setup for AgentOps. After installation, initialize AgentOps with your API key (preferably from an environment variable). This enables automatic instrumentation of supported LLM and agent framework calls. Remember to call `load_dotenv()` before `agentops.init()` if you're using a `.env` file.

import agentops
import os
from dotenv import load_dotenv

# Load environment variables (recommended for API keys)
load_dotenv()

# Initialize AgentOps
# The API key can be passed directly or set as an environment variable AGENTOPS_API_KEY
# Get your API key from the AgentOps Dashboard (app.agentops.ai)
AGENTOPS_API_KEY = os.getenv("AGENTOPS_API_KEY", "")
agentops.init(AGENTOPS_API_KEY)

print("AgentOps initialized! Any supported LLM or agent framework calls will now be tracked.")

# Example with an OpenAI call (if openai is installed and configured)
# from openai import OpenAI
# client = OpenAI()
# completion = client.chat.completions.create(
#     model="gpt-3.5-turbo",
#     messages=[
#         {"role": "system", "content": "You are a helpful assistant."}, 
#         {"role": "user", "content": "Hello!"}
#     ]
# )
# print(completion.choices.message.content)

# It's good practice to explicitly end the session, especially for single-run scripts.
agentops.end_session('Success')
print("AgentOps session ended.")

view raw JSON →