AI cost attribution and change detection for developers
Project description
Veritas
AI cost observability for developers. Track token usage, costs, and latency across every LLM call — automatically. Spot cost regressions before they hit production.
pip install veritas-sdk[anthropic]
# or
pip install veritas-sdk[openai]
# or
pip install veritas-sdk[all]
What it does
Veritas wraps your existing Anthropic or OpenAI client with a transparent proxy. Every API call is tracked silently in the background — your application code stays identical.
For every call, Veritas captures:
| Field | Description |
|---|---|
feature |
The feature name you assign |
model |
Model used (e.g. claude-3-haiku, gpt-4o-mini) |
tokens_in / tokens_out |
Input and output token counts |
cost_usd |
Computed cost based on current pricing |
latency_ms |
End-to-end request time |
code_version |
Current git commit hash (auto-detected) |
Events are sent to a Veritas dashboard where you can track spend over time, break costs down by feature, and compare costs between code versions.
Quickstart
1. Configure
import veritas
veritas.init(
api_key="sk-vrt-your-key-here",
endpoint="https://your-veritas-server.com/api/v1/events",
)
Alternatively, use environment variables — Veritas auto-configures on import:
VERITAS_API_KEY=sk-vrt-your-key-here
VERITAS_API_URL=https://your-veritas-server.com/api/v1/events
2. Wrap your client
Anthropic:
import anthropic
import veritas
veritas.init(api_key="sk-vrt-...", endpoint="https://your-server.com/api/v1/events")
client = veritas.Anthropic(
anthropic.Anthropic(),
feature_name="chat_search", # group calls by feature in the dashboard
)
response = client.messages.create(
model="claude-3-haiku-20240307",
max_tokens=256,
messages=[{"role": "user", "content": "Hello!"}],
)
# ^ tracked automatically — response is unchanged
OpenAI:
import openai
import veritas
veritas.init(api_key="sk-vrt-...", endpoint="https://your-server.com/api/v1/events")
client = veritas.OpenAI(
openai.OpenAI(),
feature_name="summarizer",
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
Streaming works too — just pass stream=True as normal.
3. Use the @track decorator (alternative)
from veritas import track
@track(feature="document_summary")
def summarize(text: str):
return anthropic_client.messages.create(...) # any call that returns usage data
Safety guarantees
- Never crashes your app — all tracking is fire-and-forget; exceptions are swallowed silently
- No prompt data transmitted — only metadata (tokens, cost, latency, model, commit hash)
- Async-safe — uses
asyncio.to_threadin async contexts so the event loop is never blocked - Zero-config git integration — commit hash is auto-detected via
git rev-parse
Requirements
- Python 3.9+
requests(for HTTP sink)anthropic>=0.39(if usingveritas-sdk[anthropic])openai>=1.0.0(if usingveritas-sdk[openai])
Links
- GitHub
- Dashboard — request access at team@veritas.dev
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 veritas_sdk-0.1.1.tar.gz.
File metadata
- Download URL: veritas_sdk-0.1.1.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e1d8fc1ff56bf64bd7af1f06aaf7ee46a3933881936e704fdebe3a50e290280
|
|
| MD5 |
bdad1f88b6d15ba918c4e8b825844fdb
|
|
| BLAKE2b-256 |
4c0dcb51cf154172e933def4a774a747883e6a0f0d096914ddcbf811b4239d16
|
File details
Details for the file veritas_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: veritas_sdk-0.1.1-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf1b374cfef16b04f250c2f237e33dd3756f5a49a761f8077233852b00b39b7e
|
|
| MD5 |
e438aaf0eeee6c3988fc81c927e537db
|
|
| BLAKE2b-256 |
f86058b59b41a0d78bf3de0ee26e4c512738a8b85cf90e8c43526fd5b824f475
|