Skip to main content

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_thread in 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 using veritas-sdk[anthropic])
  • openai>=1.0.0 (if using veritas-sdk[openai])

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

veritas_sdk-0.1.1.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

veritas_sdk-0.1.1-py3-none-any.whl (17.5 kB view details)

Uploaded Python 3

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

Hashes for veritas_sdk-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7e1d8fc1ff56bf64bd7af1f06aaf7ee46a3933881936e704fdebe3a50e290280
MD5 bdad1f88b6d15ba918c4e8b825844fdb
BLAKE2b-256 4c0dcb51cf154172e933def4a774a747883e6a0f0d096914ddcbf811b4239d16

See more details on using hashes here.

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

Hashes for veritas_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bf1b374cfef16b04f250c2f237e33dd3756f5a49a761f8077233852b00b39b7e
MD5 e438aaf0eeee6c3988fc81c927e537db
BLAKE2b-256 f86058b59b41a0d78bf3de0ee26e4c512738a8b85cf90e8c43526fd5b824f475

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page