Prerequisites
The Avaliar Python SDK requires Python 3.13 or higher.
Installation
Install the SDK from PyPI:For local detection mode
If you want to run detectors locally on your own infrastructure, also install the evaluation engine:avaliar_eval is only needed when using detection_mode="local". Cloud detection (detection_mode="cloud") works without it.Environment Variables
Configure the SDK through environment variables. You can set them in your shell, a.env file, or your deployment platform.
| Variable | Required | Default | Description |
|---|---|---|---|
AVALIAR_API_KEY | Yes | — | Your API key from the Avaliar dashboard |
AVALIAR_API_URL | No | https://api.avaliar.ai/v1 | API endpoint URL |
OPENAI_API_KEY | No | — | Required when using detection_mode="local" |
- Shell
- .env file
Basic Usage
Once installed and configured, import the SDK and start tracing your LLM calls:@traceable decorator automatically captures inputs, outputs, latency, and token usage — then submits the trace to the Avaliar platform in the background.
You can get your API key from the API Keys page in the Avaliar dashboard. Each key is scoped to your organization and can be revoked at any time.
Next Steps
@traceable Decorator
Learn how to instrument your LLM functions with automatic tracing.
Detection
Enable safety detection on your traced calls.
AvaliarBaseLLM
Implement the LLM interface for benchmarks and evaluations.
Error Handling
Handle errors and configure retry behavior.