Lightweight AI agent observability SDK — traces, quality scores, cost tracking
Project description
veloscope
Lightweight AI agent observability — traces, quality scores, and cost tracking in 2 lines.
import veloscope
veloscope.init(api_key="vs_...")
Installation
pip install veloscope
Quick Start
import veloscope
veloscope.init(api_key="vs_your_key_here") # or set VELOSCOPE_API_KEY env var
@veloscope.trace("my-agent")
def run_agent(query: str) -> str:
result = retrieve_docs(query)
return generate_answer(result)
@veloscope.span("retrieve-docs", span_type="tool")
def retrieve_docs(query: str) -> list[str]:
...
Every call to run_agent() creates a trace. Nested @span calls are linked automatically. No configuration beyond init().
Environment Variable
export VELOSCOPE_API_KEY=vs_your_key_here
veloscope.init() # picks up key from env automatically
API
veloscope.init(api_key=None, api_url=None, auto_patch=True)
Initializes the SDK. Call once at startup. If no API key is provided (and VELOSCOPE_API_KEY is not set), the SDK silently no-ops — safe to leave in production code.
| Parameter | Default | Description |
|---|---|---|
api_key |
None |
Your Veloscope API key |
api_url |
Veloscope cloud | Override for self-hosted |
auto_patch |
True |
Auto-instrument openai/anthropic clients |
@veloscope.trace(name=None)
Marks a function as the root of a trace. Each call creates a new trace ID.
@veloscope.span(name=None, span_type="custom")
Marks a function as a span within the current trace. Must be called inside a @trace-decorated function (or a function called by one). Orphan spans (no active trace) are silently skipped.
span_type values: "llm", "tool", "retrieval", "custom"
veloscope.flush()
Manually flush all buffered spans to the API. Called automatically on process exit and every 5 seconds by a background thread.
Graceful Degradation
- No API key → SDK is a no-op, zero overhead
- API unreachable → spans are silently dropped, your code continues
- Exceptions in instrumented functions propagate normally
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 veloscope-0.1.0.tar.gz.
File metadata
- Download URL: veloscope-0.1.0.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87ec9d880c9a4db0955813ac5ab66ecc42ca036ff2e6d0c5b8a038234319999f
|
|
| MD5 |
b8a8924a0028e28b5abbec56ddc96bf3
|
|
| BLAKE2b-256 |
008cef4f9e50c03b399dd5c1bee676201ccfcbfa9a91a23697a0d323d9b67dc5
|
File details
Details for the file veloscope-0.1.0-py3-none-any.whl.
File metadata
- Download URL: veloscope-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b9a5d48d7eaefe510d68911649d0ee107444a2bc071693f136291112c8459627
|
|
| MD5 |
840ae8e91ba237dbe6d42191d937941c
|
|
| BLAKE2b-256 |
6e2e71ae1ffcd9706ba5135fb7c43c2480842dc1f6365f7bbee8fc630cd6e745
|