Installation
Install RDK using pip or uv:Basic Setup
1. Set your API key
2. Initialize and trace
Callinit() to start tracing — all LLM calls are captured automatically:
@observe to group multiple calls into a single trace:
3. Shutdown gracefully
Flush remaining traces before your app exits:Complete Example
Custom Configuration
Need custom settings? Callinit() before your first @observe call:
Configuration Options
| Parameter | Type | Default | Description |
|---|---|---|---|
api_key | str | RDK_API_KEY env var | Your RDK API key |
endpoint | str | https://collector.021labs.ai | Collector URL |
batch_size | int | 10 | Number of spans per batch |
flush_interval | float | 5.0 | Seconds between auto-flushes |
timeout | float | 30.0 | HTTP request timeout in seconds |
sample_rate | float | 1.0 | Fraction of traces to capture (0–1) |
redact_pii | bool | False | Enable built-in PII redaction |
redactor | Callable | None | Custom redaction function |
debug | bool | False | Enable verbose debug logging |
enabled | bool | True | Set to False to disable all tracing |
mode | str | "default" | Operating mode: "default", "test", or "eval" |
on_error | Callable | None | Callback for transport errors |
instrument_langchain | bool | True | Auto-instrument LangChain |
instrument_anthropic | bool | True | Auto-instrument Anthropic SDK |
instrument_openai | bool | True | Auto-instrument OpenAI SDK |
instrument_gemini | bool | True | Auto-instrument Gemini SDK |
Environment Variables
| Variable | Effect |
|---|---|
RDK_API_KEY | API key for authentication |
RDK_ENDPOINT | Override the default collector URL |
RDK_MODE | Operating mode (default, test, eval) |
What Gets Traced?
RDK automatically captures all LLM calls:- Token Usage — Prompt, completion, and total tokens
- Cost — Calculated automatically based on model pricing
- Timing — Start time, end time, and duration
- Model Info — Model name and provider
- Errors — Exception messages
capture_input=True and capture_output=True on @observe.
Next Steps
Anthropic Integration
Set up Claude tracing
PII Redaction
Protect sensitive data
Testing
Write tests without real API calls
Synthetic Worlds
Simulate tool calls for fast iteration
API Reference
Full parameter reference

