api-cost-tracker
The client for the Synth Insight Labs API cost tracker. It records what every API
call costs to https://api.synthinsightlabs.com without ever breaking the call it
measures. Standard library only; macOS and Linux.
from api_cost_tracker import track, track_tokens, log_call
response = client.messages.create(...) # any provider SDK
track(response, "anthropic", project="my-project", caller="summarizer")
track_tokens("anthropic", "claude-haiku-4-5", 1200, 300, project="my-project") # raw HTTP calls
log_call("vercel", service="blob", project="my-project") # non-AI APIs
- Providers:
anthropic,openai,xai,google,openrouter(records OpenRouter's billedusage.cost). - Batch API calls: pass
service="batches"totrack()ortrack_tokens(). The server then prices the row at the provider's batch rate (half price). - Never raises. A record that can't be sent goes to an offline buffer at
~/.local/share/api_trust_tracker/buffer.db, and each later successful call sends a few buffered rows too. A record that is lost anyway is logged at WARNING. - Silent in test suites. While a pytest test runs, the client sends, buffers and
drains nothing, so faking
_post_to_servercan't leak rows either way. A test of the real send path setsAPI_COST_TRACKER_SEND_IN_TESTS=1and pointsapi_cost_tracker.buffer.BUFFER_DB_PATHat a temporary file. New in 0.2.3. - Configuration:
COST_TRACKER_API_KEY(required by the server) andCOST_TRACKER_URL(defaulthttps://api.synthinsightlabs.com), from the environment.
Renamed from api-trust-tracker in 0.2.0. That package now only re-exports this
one, and the buffer keeps its old directory so both versions share it.
Metadata
Release files for api-cost-tracker 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| api_cost_tracker-0.2.3.tar.gz | 18.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| api_cost_tracker-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.1 kB
Release files / api_cost_tracker-0.2.3.tar.gz
| Download URL | api_cost_tracker-0.2.3.tar.gz |
|---|---|
| Size | 18.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2da01e538c621caec77c356c459dbaa261ed2684d3856f3ff965a24a586a53a9
|
|
BLAKE2b-256 checksum How to use checksums |
c9bf11ca7cb89496eb75f3ee81426ae1a730ebd1ed82486fed6d3aa602c170c9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / api_cost_tracker-0.2.3-py3-none-any.whl
| Download URL | api_cost_tracker-0.2.3-py3-none-any.whl |
|---|---|
| Size | 11.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c693a5bf6ce8018692afba8f098b0de653aedcc5469475e0534d0d4f89e056fc
|
|
BLAKE2b-256 checksum How to use checksums |
a99ca2b6bafb064164196df496d0a5c663175c65f0fab07b87d9bff0e9cba514
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for api-cost-tracker 0.2.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.