Free, serverless LLM observability SDK. Track cost, latency, and behavior with a single decorator.
Project description
Runetrace — Python SDK
Because you shouldn't need a $500/month tool to know what your AI is doing.
Free, serverless LLM observability. Track cost, latency, tokens, and behavior of every LLM call with a single decorator.
Features
- Zero-Config Tracking: One decorator (
@track_llm) captures everything. - Cost Calculation: Built-in pricing logic for 30+ models (GPT-4o, Claude 3.5 Sonnet, Gemini 1.5, etc.).
- Async & Batching: Non-blocking background uploads with automatic retry and graceful shutdown.
- Serverless Ready: Direct-to-Supabase architecture. No middleware required.
Installation
pip install runetrace
Quick Start
import runetrace
from openai import OpenAI
# Configure with your Supabase project
runetrace.configure(
supabase_url="https://your-project.supabase.co",
anon_key="your-supabase-anon-key",
api_key="your-runetrace-api-key", # rt_live_xxx
project_id="my-app"
)
client = OpenAI()
# Wrap any LLM function (sync or async)
@runetrace.track_llm
def ask(prompt):
return client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": prompt}]
)
response = ask("What is the meaning of life?")
# ✅ Prompt, response, cost, latency, tokens — all tracked automatically in the background
Manual Logging
If you prefer not to use decorators, you can log directly:
runetrace.log(
model="gpt-4o",
prompt="Hello",
response="Hi there!",
prompt_tokens=5,
completion_tokens=3,
latency_ms=230,
function_name="greet"
)
Configuration
runetrace.configure(
supabase_url="https://xxx.supabase.co", # Required
api_key="rt_live_xxx", # Required
anon_key="eyJxxx", # Supabase anon key
project_id="my-app", # Default: 'default'
batch_size=10, # Logs batched before send
flush_interval=5.0, # Seconds between auto-flush
max_retries=3, # Retry on failure
user_id="user-123", # Per-user tracking
session_id="session-abc", # Group related calls
tags=["production", "v2"], # Categorization
metadata={"env": "prod"}, # Custom metadata
)
Environment Variables
All configuration options can also be set via environment variables. This is the recommended approach for production:
| Variable | Description |
|---|---|
RUNETRACE_SUPABASE_URL |
Supabase project URL |
RUNETRACE_API_KEY |
Runetrace API key |
RUNETRACE_ANON_KEY |
Supabase anon key |
RUNETRACE_PROJECT_ID |
Project ID string |
RUNETRACE_USER_ID |
Default user ID |
Flush on Exit
The SDK uses atexit to automatically flush any pending logs when your Python script finishes. If you need manual control (e.g., in AWS Lambda before freeze), you can call:
runetrace.flush()
License
MIT
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 runetrace-0.1.2.tar.gz.
File metadata
- Download URL: runetrace-0.1.2.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fe1034c75032d79abc69013815df7bf71e0fcd0c4f293acffa2a5300fc5b49d2
|
|
| MD5 |
7aae9e06964eb046ccda5ed17379ad61
|
|
| BLAKE2b-256 |
5d2c99944cb63670a93a17e7c5bbfa9aec2cd713210a14406ea4f332343ab090
|
File details
Details for the file runetrace-0.1.2-py3-none-any.whl.
File metadata
- Download URL: runetrace-0.1.2-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e530de27fc380110705e537d89b483aff2ab963a5b1c8352954de903eb56444
|
|
| MD5 |
1f0ef65fdd9215d02d95b543bf3e2823
|
|
| BLAKE2b-256 |
fd12a2361d4f39c8c810af48185669268b961ba0d01b7794368545fdc1b82715
|