API Reference
Peaky Peek provides a comprehensive REST API for querying sessions, traces, replay, search, analytics, and more.
Base URL
Authentication
API key authentication via X-API-Key header:
Routers Overview
The API is organized into 11 routers:
- Sessions — Session CRUD operations
- Traces — Trace event queries
- Replay — Time-travel and checkpoint replay
- Search — Cross-session trace search
- Analytics — Aggregated metrics and insights
- Cost — Token usage and cost tracking
- Comparison — Session comparison
- Entity — Entity extraction and tracking
- Policy — Prompt policy analysis
- Cross-Session — Multi-agent coordination
- Auth — API key management
Session Routes
List Sessions
Query parameters: - limit — Number of sessions to return (default: 50) - offset — Pagination offset (default: 0) - agent_name — Filter by agent name - framework — Filter by framework - status — Filter by status (running, completed, error)
Response:
{
"sessions": [
{
"id": "uuid",
"agent_name": "weather_agent",
"framework": "custom",
"started_at": "2024-01-01T00:00:00Z",
"ended_at": "2024-01-01T00:00:05Z",
"status": "completed",
"total_tokens": 1000,
"total_cost_usd": 0.01,
"tool_calls": 5,
"llm_calls": 2,
"errors": 0
}
],
"total": 100
}
Get Session
Response:
{
"id": "uuid",
"agent_name": "weather_agent",
"framework": "custom",
"started_at": "2024-01-01T00:00:00Z",
"ended_at": "2024-01-01T00:00:05Z",
"status": "completed",
"total_tokens": 1000,
"total_cost_usd": 0.01,
"tool_calls": 5,
"llm_calls": 2,
"errors": 0,
"config": {},
"tags": []
}
Delete Session
Trace Routes
Get Session Traces
Query parameters: - event_type — Filter by event type - limit — Number of events to return
Response:
{
"events": [
{
"id": "uuid",
"session_id": "uuid",
"parent_id": null,
"event_type": "agent_start",
"timestamp": "2024-01-01T00:00:00Z",
"name": "weather_agent",
"data": {},
"metadata": {},
"importance": 0.5,
"sequence": 0
}
]
}
Get Decision Tree
Response:
{
"nodes": [
{
"id": "uuid",
"event_type": "decision",
"name": "call_weather_api",
"children": ["uuid2", "uuid3"]
}
]
}
Get Normalized Trace Bundle
Returns a normalized bundle with all trace data, analysis, and metadata.
Replay Routes
Get Checkpoints
Response:
{
"checkpoints": [
{
"id": "uuid",
"session_id": "uuid",
"event_id": "uuid",
"sequence": 5,
"state": {},
"timestamp": "2024-01-01T00:00:05Z",
"importance": 0.8
}
]
}
Start Replay
Request body:
{
"from_event_id": "uuid",
"breakpoint_rules": [
{
"event_type": "error",
"tool_name": null,
"confidence_min": null,
"safety_outcome": null
}
]
}
Search Routes
Search Traces
Request body:
Response:
{
"results": [
{
"event_id": "uuid",
"session_id": "uuid",
"event_type": "error",
"data": {},
"score": 0.95
}
]
}
Analytics Routes
Get Session Analytics
Response:
{
"summary": {
"total_events": 100,
"decisions": 20,
"tool_calls": 30,
"llm_calls": 10,
"errors": 2
},
"rankings": [
{
"event_id": "uuid",
"score": 0.9,
"reason": "High error impact"
}
],
"clusters": [
{
"cluster_id": "uuid",
"events": ["uuid1", "uuid2"],
"description": "API timeout pattern"
}
]
}
Get Global Analytics
Query parameters: - start_date — Start date filter - end_date — End date filter
Cost Routes
Get Session Cost
Response:
{
"total_cost_usd": 0.05,
"total_tokens": 5000,
"by_model": {
"gpt-4o": {
"input_tokens": 3000,
"output_tokens": 2000,
"cost_usd": 0.05
}
}
}
Get Cost Summary
Query parameters: - start_date — Start date filter - end_date — End date filter
Comparison Routes
Compare Sessions
Request body:
Response:
{
"differences": [
{
"field": "tool_calls",
"session_1": 5,
"session_2": 3,
"diff": 2
}
],
"unique_to_session_1": [...],
"unique_to_session_2": [...]
}
Entity Routes
Extract Entities
Response:
{
"entities": [
{
"name": "Seattle",
"type": "location",
"count": 5,
"first_seen": "uuid",
"events": ["uuid1", "uuid2"]
}
]
}
Policy Routes
Get Policy Analysis
Response:
Cross-Session Routes
Get Multi-Agent Coordination
Response:
{
"speakers": [
{
"name": "planner",
"turns": 10,
"tools_used": ["search", "analyze"]
}
],
"topology": "hierarchical"
}
Auth Routes
Create API Key
Request body:
Response:
{
"key_id": "uuid",
"api_key": "ad_live_...",
"name": "My Key",
"created_at": "2024-01-01T00:00:00Z"
}
List API Keys
Delete API Key
System Routes
Health Check
Response:
System Info
Response:
Streaming
Server-Sent Events (SSE)
Subscribe to live events for a session. Returns text/event-stream with real-time event updates.
Error Responses
All endpoints return consistent error responses:
Common error codes: - session_not_found — Session does not exist - invalid_request — Invalid request parameters - unauthorized — Missing or invalid API key - internal_error — Server error
Rate Limiting
API rate limits (if configured):
- 100 requests per minute per API key
- 1000 requests per hour per API key
Rate limit headers are included in responses:
SDK Client
Python SDK
from agent_debugger_sdk import TraceContext, init
init()
async with TraceContext(agent_name="my_agent") as ctx:
await ctx.record_decision(
reasoning="User asked for help",
confidence=0.9,
chosen_action="provide_answer",
)
HTTP Client
# List sessions
curl http://localhost:8000/api/sessions
# Get session details
curl http://localhost:8000/api/sessions/{session_id}
# Search traces
curl -X POST http://localhost:8000/api/traces/search \
-H "Content-Type: application/json" \
-d '{"query": "error", "limit": 10}'
Next Steps
- Getting Started — 5-minute quickstart
- Integrations — Framework-specific setup
- Configuration — Configuration options