Skip to main content

Agent Logs

ZeroDB agent logs capture every agent execution — inputs, outputs, tool calls, latency, and errors — giving you a full audit trail and performance analytics.

Log an Agent Execution

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"agent_id": "code-reviewer-v2",
"session_id": "session-abc123",
"input": {"task": "Review PR #42"},
"output": {"summary": "2 issues found", "severity": "low"},
"tool_calls": [
{"tool": "read_file", "args": {"path": "app/main.py"}, "duration_ms": 12}
],
"duration_ms": 3200,
"status": "success"
}'

List Agent Logs

curl "https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs?agent_id=code-reviewer-v2&limit=50" \
-H "x-api-key: $API_KEY"

Get Stats

curl "https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs/stats" \
-H "x-api-key: $API_KEY"

Returns total executions, success rate, average latency, and per-agent breakdowns.

Export Logs

curl -X POST https://api.ainative.studio/api/v1/projects/{project_id}/database/agent-logs/export \
-H "x-api-key: $API_KEY" \
-H "Content-Type: application/json" \
-d '{"start_date": "2026-05-01", "end_date": "2026-05-31", "format": "jsonl"}'

Python SDK

import requests

API_KEY = "your-api-key"
PROJECT_ID = "your-project-id"
BASE = f"https://api.ainative.studio/api/v1/projects/{PROJECT_ID}/database/agent-logs"
headers = {"x-api-key": API_KEY, "Content-Type": "application/json"}

# Log an execution
r = requests.post(BASE, headers=headers, json={
"agent_id": "my-agent",
"input": {"query": "summarize the report"},
"output": {"result": "The report covers Q1 financials..."},
"duration_ms": 1850,
"status": "success"
})
log_id = r.json()["log_id"]

# Get performance stats
stats = requests.get(f"{BASE}/stats", headers=headers).json()
print(f"Success rate: {stats['success_rate']}%")
print(f"Avg latency: {stats['avg_duration_ms']}ms")

Endpoints

MethodPathDescription
POST/database/agent-logsLog an agent execution
GET/database/agent-logsList logs (filterable by agent_id, status, date)
GET/database/agent-logs/{id}Get a specific log entry
GET/database/agent-logs/statsAggregate performance statistics
DELETE/database/agent-logs/{id}Delete a log entry
POST/database/agent-logs/exportExport logs to JSONL/CSV
GET/database/agents/activeList currently active agents
GET/database/agents/tracesGet execution traces