AgentOps dashboard explained
Quick answer
The
AgentOps dashboard provides real-time observability and monitoring for AI agents by automatically tracking all LLM calls after agentops.init(). It offers session management, logs, and performance metrics to help developers debug and optimize AI workflows.PREREQUISITES
Python 3.8+AgentOps API keypip install agentops
Setup
Install the agentops Python package and set your API key as an environment variable. Initialize agentops in your Python script to enable automatic tracking of AI agent calls.
pip install agentops
# In your shell
export AGENTOPS_API_KEY="your_agentops_api_key" output
Collecting agentops Downloading agentops-1.0.0-py3-none-any.whl (10 kB) Installing collected packages: agentops Successfully installed agentops-1.0.0
Step by step
Use agentops.init() to start tracking. Wrap your AI agent calls, then view the dashboard online to monitor sessions, logs, and metrics.
import os
import agentops
from openai import OpenAI
# Initialize AgentOps with your API key
agentops.init(api_key=os.environ["AGENTOPS_API_KEY"])
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
# Start a session (optional)
session = agentops.start_session(tags=["example-agent"])
# Make a chat completion call
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Explain AgentOps dashboard."}]
)
print("Response:", response.choices[0].message.content)
# End the session
agentops.end_session("Success") output
Response: The AgentOps dashboard provides real-time monitoring and detailed logs of your AI agent's interactions, helping you optimize and debug your workflows.
Common variations
You can use agentops with asynchronous code, other LLM providers, or integrate it with frameworks that support OpenAI-compatible clients. Automatic tracking works after agentops.init() without code changes.
import asyncio
import os
import agentops
from openai import OpenAI
agentops.init(api_key=os.environ["AGENTOPS_API_KEY"])
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
async def async_call():
response = await client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Async AgentOps demo."}]
)
print("Async response:", response.choices[0].message.content)
asyncio.run(async_call()) output
Async response: This demonstrates AgentOps tracking with asynchronous OpenAI calls.
Troubleshooting
- If you see no data in the dashboard, ensure
agentops.init()is called before any AI client calls. - Verify your
AGENTOPS_API_KEYenvironment variable is set correctly. - Check network connectivity to
agentopsservers.
Key Takeaways
- Call
agentops.init()early to enable automatic AI call tracking. - Use
agentops.start_session()andagentops.end_session()to group related calls. - The dashboard provides logs, metrics, and session views for debugging AI agents.
- AgentOps supports synchronous and asynchronous OpenAI-compatible clients.
- Ensure environment variables for API keys are correctly set to avoid tracking failures.