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 your Veritas dashboard where you can track spend over time, break costs down by feature, and automatically detect cost regressions between code versions.
Dashboard
Sign up free at web-production-82424.up.railway.app
Overview
The main dashboard shows your total spend, call volume, token usage, and average latency — with a week-over-week health banner that tells you if costs are rising or stable.
Cost by Commit
Every event is tagged with the git commit hash it ran on — automatically, with no configuration. The commit chart lets you see exactly which code version changed your costs.
Regression Detection
The regressions page automatically compares your two most recent commits across every tracked feature — no manual commit entry. Red rows = cost went up.
Trends
30-day cost and call volume trends with projected monthly spend and week-over-week comparison.
Feature Analytics
Break down costs by feature — total spend, average cost per call, error rate, and percentage share of your total AI bill.
Model Analytics
See which models you're spending on and how token usage is distributed across them.
Quickstart
1. Sign up and get your API key
Create a free account, then go to Settings to create a project and get your API key.
2. Configure
import veritas
veritas.init(
api_key="sk-vrt-your-key-here",
endpoint="https://web-production-82424.up.railway.app/api/v1/events",
)
Or use environment variables — Veritas auto-configures on import:
VERITAS_API_KEY=sk-vrt-your-key-here
VERITAS_API_URL=https://web-production-82424.up.railway.app/api/v1/events
3. Wrap your client
Anthropic:
import anthropic
import veritas
veritas.init(api_key="sk-vrt-...", endpoint="https://web-production-82424.up.railway.app/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://web-production-82424.up.railway.app/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.
4. 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
CLI — Compare commits
After collecting data, compare any two commits from the terminal:
veritas diff --feature chat_search --from abc1234 --to def5678
---------------------------------------------------------------
Metric |Commit A (Base) |Commit B (Target)|Delta
---------------------------------------------------------------
Samples |120 |134 |-
Avg Cost/Req |$0.000412 |$0.000589 |$0.000177 (42.96%)
Avg Tokens In |312.4 |451.2 |138.8
Avg Tokens Out |89.1 |112.3 |23.2
---------------------------------------------------------------
Verdict:
❌ REGRESSION DETECTED: Cost increased beyond acceptable thresholds.
Exits with code 1 on regression — drop it straight into CI:
# .github/workflows/cost-check.yml
- name: Check cost regression
run: veritas diff --feature chat_search --from ${{ github.event.before }} --to ${{ github.sha }}
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
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.2.tar.gz.
File metadata
- Download URL: veritas_sdk-0.1.2.tar.gz
- Upload date:
- Size: 40.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
19c2082456ac774dafdff8af19ba2ec96db4f04dc1cabccc62585db1848bbf53
|
|
| MD5 |
0d2daace36efc1e28b2f0cf295e73af8
|
|
| BLAKE2b-256 |
bfedea5e7730fbd9c0af92ca87bb475b117d23ea75bae2a3e18920314b97d822
|
File details
Details for the file veritas_sdk-0.1.2-py3-none-any.whl.
File metadata
- Download URL: veritas_sdk-0.1.2-py3-none-any.whl
- Upload date:
- Size: 24.3 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 |
6895010e54067cb2f1ec95474c89257f6125b9ae120d4775624584cf77878b24
|
|
| MD5 |
1e7e813716cc9ffa5690d98b75b56b27
|
|
| BLAKE2b-256 |
b835819641439198a2813a408e961d3768518b66733e2c5b90aa54fc7f854010
|