AI Agent Observability Platform SDK
Project description
Prela SDK
Open-source Python SDK for AI agent observability, testing, and debugging.
Prela provides comprehensive instrumentation, evaluation frameworks, and replay capabilities for AI agents built with OpenAI, Anthropic, LangChain, LlamaIndex, CrewAI, AutoGen, LangGraph, and more.
Features
- 🔍 Auto-instrumentation - Zero-code observability for 10+ AI frameworks
- 📊 Evaluation Framework - 17+ assertion types for testing agent behavior
- 🔄 Replay Engine - Deterministic replay for debugging and testing
- 📤 Multiple Exporters - Console, file, HTTP, and ClickHouse outputs
- 🎯 Multi-Agent Support - Track complex agent interactions and delegations
- 🛠️ CLI Tools - Command-line interface for trace management
- 🧪 Production Ready - 836+ tests with comprehensive coverage
Installation
pip install prela
With Optional Integrations
# Install specific integrations
pip install prela[openai] # OpenAI SDK
pip install prela[anthropic] # Anthropic/Claude SDK
pip install prela[langchain] # LangChain
pip install prela[llamaindex] # LlamaIndex
# Install all integrations
pip install prela[all]
# Install with development tools
pip install prela[dev]
# Install with CLI tools
pip install prela[cli]
Quick Start
Basic Usage
import prela
# Initialize with console output
prela.init(service_name="my-agent", exporter="console")
# Your AI agent code here
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role": "user", "content": "Hello!"}]
)
# Prela automatically traces the OpenAI call
Auto-Instrumentation
Prela automatically instruments supported frameworks:
import prela
# One-line initialization
prela.init(service_name="my-app", exporter="console")
# All these frameworks are automatically traced:
# - OpenAI API calls
# - Anthropic/Claude API calls
# - LangChain chains and agents
# - LlamaIndex queries
# - CrewAI tasks
# - AutoGen conversations
# - LangGraph workflows
# - OpenAI Swarm agents
Manual Instrumentation
from prela import trace
@trace
def my_agent_function(user_input: str):
# Your agent logic here
return process_input(user_input)
# Or use context managers
from prela import tracer
with tracer.start_span("complex-operation") as span:
result = do_something()
span.set_attribute("result_count", len(result))
Evaluation Framework
from prela.evals import EvalRunner, TestCase, Assertion
# Define test cases
test_cases = [
TestCase(
name="greeting-test",
input={"message": "Hello"},
assertions=[
Assertion.contains("hello", case_sensitive=False),
Assertion.max_length(100)
]
)
]
# Run evaluations
runner = EvalRunner()
results = runner.run(my_agent_function, test_cases)
results.print_summary()
Replay Engine
from prela.replay import ReplayEngine
# Load a trace
engine = ReplayEngine()
trace = engine.load_trace("trace_id_123")
# Replay with comparison
replay_result = engine.replay(trace)
comparison = engine.compare(trace, replay_result)
print(f"Similarity: {comparison.similarity_score}")
Supported Frameworks
| Framework | Auto-Instrumentation | Manual Tracing | Version Support |
|---|---|---|---|
| OpenAI | ✅ | ✅ | >=1.0.0 |
| Anthropic | ✅ | ✅ | >=0.18.0 |
| LangChain | ✅ | ✅ | >=0.1.0 |
| LlamaIndex | ✅ | ✅ | >=0.9.0 |
| CrewAI | ✅ | ✅ | >=0.1.0 |
| AutoGen | ✅ | ✅ | >=0.2.0 |
| LangGraph | ✅ | ✅ | >=0.0.20 |
| OpenAI Swarm | ✅ | ✅ | >=0.1.0 |
| N8N | ✅ | ✅ | All versions |
Exporters
Console Exporter
prela.init(exporter="console")
File Exporter
prela.init(
exporter="file",
file_path="traces.jsonl"
)
HTTP Exporter
prela.init(
exporter="http",
endpoint="https://api.prela.io",
api_key="your-api-key"
)
ClickHouse Exporter
prela.init(
exporter="clickhouse",
clickhouse_host="localhost",
clickhouse_port=8123
)
CLI Tools
# List traces
prela list
# Show trace details
prela show <trace-id>
# Show most recent trace
prela last
# Search traces
prela search "error"
# Show failed traces
prela errors
# Interactive explorer
prela explore
Evaluation Assertions
Prela includes 17+ assertion types:
Structural Assertions:
contains()- Check for substringregex()- Pattern matchingjson_schema()- Validate JSON structurelength()- Check output length
Semantic Assertions:
similarity()- Embedding-based similarity
Tool Assertions:
tool_called()- Verify tool usagetool_args()- Validate tool argumentstool_sequence()- Check tool call order
Multi-Agent Assertions:
agent_used()- Verify agent participationtask_completed()- Check task completiondelegation_pattern()- Validate delegationno_circular_delegation()- Prevent cyclescollaboration_count()- Track interactions
Advanced Features
Sampling
from prela.core import AlwaysOnSampler, ProbabilitySampler, RateLimitSampler
# Always sample
prela.init(sampler=AlwaysOnSampler())
# Sample 10% of traces
prela.init(sampler=ProbabilitySampler(0.1))
# Sample max 100 traces/second
prela.init(sampler=RateLimitSampler(100))
Context Propagation
from prela import get_current_span
def my_function():
span = get_current_span()
span.set_attribute("custom_field", "value")
span.add_event("checkpoint reached")
Custom Exporters
from prela.exporters import SpanExporter
class MyExporter(SpanExporter):
def export(self, spans):
for span in spans:
# Custom export logic
pass
prela.init(exporter=MyExporter())
Examples
See the examples/ directory for complete working examples:
- OpenAI Chatbot
- Anthropic Claude Agent
- LangChain RAG
- CrewAI Multi-Agent
- Evaluation Framework
- Replay Engine
Documentation
Full documentation is available at docs.prela.dev
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development Setup
# Clone the repository
git clone https://github.com/garrettw2200/prela-sdk.git
cd prela-sdk
# Install development dependencies
pip install -e ".[dev,all]"
# Run tests
pytest
# Run linters
ruff check .
black .
mypy prela
Community
- GitHub Discussions
- Issue Tracker
- Discord Community (coming soon)
License
Apache License 2.0 - see LICENSE for details.
Acknowledgments
Built with ❤️ by the Prela team and contributors.
Star this repo if you find it useful! ⭐
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file prela-0.1.0.tar.gz.
File metadata
- Download URL: prela-0.1.0.tar.gz
- Upload date:
- Size: 334.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfc3e2b9dc8ff8d796b478165e04d5311d78f4fdcb7bf7b39a17e1cdfafaaafb
|
|
| MD5 |
f32fb92d954f0e253d52f4a2dbbdb6cc
|
|
| BLAKE2b-256 |
c50ffb8dcffd7067613f07a4942ef31cbec9c813ee9233a69cf4d410aaa4e9d8
|
Provenance
The following attestation bundles were made for prela-0.1.0.tar.gz:
Publisher:
publish-pypi.yml on garrettw2200/prela-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prela-0.1.0.tar.gz -
Subject digest:
dfc3e2b9dc8ff8d796b478165e04d5311d78f4fdcb7bf7b39a17e1cdfafaaafb - Sigstore transparency entry: 914695448
- Sigstore integration time:
-
Permalink:
garrettw2200/prela-sdk@f3eb19a5c939923aecb8cc8450e2a32a5911e87b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/garrettw2200
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@f3eb19a5c939923aecb8cc8450e2a32a5911e87b -
Trigger Event:
release
-
Statement type:
File details
Details for the file prela-0.1.0-py3-none-any.whl.
File metadata
- Download URL: prela-0.1.0-py3-none-any.whl
- Upload date:
- Size: 197.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
45ed32a5a0048c32aa5840748fd8d45b384e073f9fd919a8bb6a9952ebcbe5c2
|
|
| MD5 |
943a2934aa13c4369610ecb0de77b142
|
|
| BLAKE2b-256 |
5007be40cb7f3f21f49629cabedd610fd7a516d9c80a620d084486bddc81331f
|
Provenance
The following attestation bundles were made for prela-0.1.0-py3-none-any.whl:
Publisher:
publish-pypi.yml on garrettw2200/prela-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
prela-0.1.0-py3-none-any.whl -
Subject digest:
45ed32a5a0048c32aa5840748fd8d45b384e073f9fd919a8bb6a9952ebcbe5c2 - Sigstore transparency entry: 914695560
- Sigstore integration time:
-
Permalink:
garrettw2200/prela-sdk@f3eb19a5c939923aecb8cc8450e2a32a5911e87b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/garrettw2200
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-pypi.yml@f3eb19a5c939923aecb8cc8450e2a32a5911e87b -
Trigger Event:
release
-
Statement type: