Observed since 20 Oct, 23:28 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
An operational monitoring library for AI agent applications
An operational monitoring library for AI agent applications that tracks token usage, costs, performance metrics, and environmental impact.
Token Counting
Cost Calculation
Performance Metrics
Environmental Impact
Logging
Visualization
You can install Agent Spy Monitor via PyPI using pip:
pip install agent-spy-monitor
from agent_spy import AgentSpy
# Initialize the monitor
spy = AgentSpy(model="gpt-4o")
# Start monitoring
spy.start()
# Your AI agent code here
input_text = "Hello, how are you?"
output_text = "I'm doing well, thank you!"
# Set token counts
spy.set_token_counts(input_text, output_text)
# End monitoring
spy.end()
# View results
print(f"Total cost: ${spy.cost:.6f}")
print(f"Total tokens: {spy.total_tokens}")
print(f"Carbon emissions: {spy.carbon_emissions:.6f} kg CO2")
from agent_spy import AgentSpy
spy = AgentSpy(model="gpt-4o")
spy.start()
# Run your CrewAI workflow
crew_output = your_crew.kickoff()
# Extract token usage from CrewAI output
spy.set_token_usage_from_crew_output(crew_output)
spy.end()
from agent_spy import AgentSpyExtended
spy = AgentSpyExtended(model="gpt-4o")
spy.start()
# Your AI operations here
spy.end()
# Show CLI summary
spy.visualize(method='cli')
# Or launch Streamlit dashboard
spy.visualize(method='streamlit')
The library supports cost calculation for various AI models:
# Disable resource monitoring for better performance
spy = AgentSpy(model="gpt-4o", enable_monitoring=False)
# Custom encoding for token counting
spy = AgentSpy(model="custom-model", encoding_name="cl100k_base")
Methods:
start(): Begin monitoringend(): Stop monitoring and calculate metricsset_token_counts(input_text, output_text): Manually set token countsset_token_usage_from_crew_output(crew_output): Extract from CrewAI outputcount_tokens(text): Count tokens in textProperties:
cost: Total cost in USDtotal_tokens: Total token countinput_tokens: Input token countoutput_tokens: Output token counttotal_time: Execution time in secondscarbon_emissions: Estimated CO₂ emissions in kgExtends AgentSpy with visualization capabilities:
Additional Methods:
visualize(method='cli'): Show CLI summaryvisualize(method='streamlit'): Launch Streamlit dashboardMIT License
Contributions are welcome! Please feel free to submit a Pull Request.
Nidhish Wakodikar
Download counts and popularity will appear here as the collector receives them.
| Version | Published | Direct dependencies | Open version |
|---|---|---|---|
| 0.1.0 | 1 Jul 2025 | 9 |
This describes our collected data; it is not a security assessment.
Shared repository data · GitHub
Observed since 20 Oct, 23:28 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package:7563f5c5920b33d29d0bf2962e4aee9bf9e7fd957e393249ab014b79b90b9564