Public API
Read-only HTTP API for accessing AgentOps trace and span data
Public API
The AgentOps Public API provides read-only HTTP access to your monitoring data. This RESTful API allows you to retrieve trace information, span details, and metrics from any application or framework, regardless of programming language.
This is a read-only API for accessing existing data. To create traces and spans, use the AgentOps SDK or our instrumentation libraries.
Base URL
All API requests should be made to:
Authentication
The API uses JWT token authentication. You’ll need to exchange your API key for a JWT token first.
Get Access Token
Convert your API key to a bearer token for API access.
Important: Bearer tokens are valid for 30 days. Store them securely and refresh before expiration.
Core Endpoints
Get Project Information
Retrieve details about your current project.
This endpoint returns information about the project associated with your API key.
Get Trace Details
Retrieve comprehensive information about a specific trace, including all its spans.
Parameters:
trace_id
(path, required): The unique identifier of the trace
Response Fields:
trace_id
: Unique trace identifierproject_id
: Associated project IDtags
: Array of tags associated with the tracespans
: Array of span summaries within the trace
Get Trace Metrics
Retrieve aggregated metrics and statistics for a trace.
Metrics Explained:
span_count
: Total number of spans in the tracesuccess_count
/fail_count
/indeterminate_count
: Status breakdown*_tokens
: Token usage breakdown by type*_cost
: Cost calculations in USD
Get Span Details
Retrieve comprehensive information about a specific span, including full attribute payloads.
Parameters:
span_id
(path, required): The unique identifier of the span
Response Fields:
attributes
: Core span data (LLM calls, tool usage, etc.)resource_attributes
: Service and infrastructure metadataspan_attributes
: Custom attributes set by your application
Get Span Metrics
Retrieve detailed metrics for a specific span.
MCP Server
AgentOps provides a Model Context Protocol (MCP) server that exposes the Public API as tools for AI assistants. This allows AI models to directly query your AgentOps data during conversations.
Configuration
Create an MCP server configuration file (typically mcp_config.json
):
Python-based configuration:
Docker-based configuration:
Available Tools
The MCP server exposes the following tools that mirror the Public API endpoints:
auth
Authorize using an AgentOps project API key.
- Parameters:
api_key
(string) - Your AgentOps project API key - Usage: The server will automatically prompt for authentication when needed
get_project
Get details about the current project.
- Parameters: None
- Returns: Project information including ID, name, and environment
get_trace
Get comprehensive trace information by ID.
- Parameters:
trace_id
(string) - The trace identifier - Returns: Trace details with associated spans
get_trace_metrics
Get aggregated metrics for a specific trace.
- Parameters:
trace_id
(string) - The trace identifier - Returns: Cost, token usage, and performance metrics
get_span
Get detailed span information by ID.
- Parameters:
span_id
(string) - The span identifier - Returns: Complete span data including attributes
get_span_metrics
Get metrics for a specific span.
- Parameters:
span_id
(string) - The span identifier - Returns: Span-specific cost and token metrics
Environment Variables
The MCP server supports the following environment variables:
AGENTOPS_API_KEY
: Your AgentOps project API keyHOST
: API endpoint (defaults tohttps://api.agentops.ai
)