Cost-tracking SDK for Anthropic, OpenAI, and Gemini Python clients
Project description
botzone-cost
Cost-tracking SDK for Anthropic, OpenAI, and Gemini Python clients. Wrap your existing client; per-call usage flows to your Cost dashboard. Adds zero measurable latency to the host call.
Install
pip install botzone-cost
Usage
from anthropic import Anthropic
from botzone_cost import wrap
client = wrap(Anthropic(), api_key="cost_sk_...", route="follow-up-draft")
Same surface for OpenAI and Gemini:
from openai import OpenAI
import google.generativeai as genai
from botzone_cost import wrap
openai_client = wrap(OpenAI(), route="summariser")
gemini = wrap(genai.GenerativeModel("gemini-2.5-flash"), route="classifier")
Options
| arg | default |
|---|---|
api_key |
env COST_API_KEY |
endpoint |
env COST_ENDPOINT or https://cost.botzone.ai |
route |
(none: strongly recommended) |
user_id |
(sha256-hashed in the SDK before send) |
feature_tag |
(none) |
enabled |
True |
capture_bodies |
False (reserved, no effect today, see below) |
What gets captured
Token counts (including Anthropic prompt-cache reads / writes and OpenAI cached
prompt tokens), latency, model, route, user id (hashed), feature tag. Computed
USD cost is added server-side from the live pricing table. The Python SDK is
metadata-only today: it does not send raw request or response bodies, and
the capture_bodies parameter is reserved for future parity with the
TypeScript SDK.
End-user identifiers passed via user_id are SHA-256 hashed in the SDK before
send; the plaintext never leaves your process.
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 botzone_cost-0.1.0.tar.gz.
File metadata
- Download URL: botzone_cost-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
564cb3ff95021e9519bfe074a0ffc687bd717efb9fbfdec932ab16dc6b7fdd46
|
|
| MD5 |
02264e739bd178c0b4575ed22a12380f
|
|
| BLAKE2b-256 |
1d0891092b0a0fbf109849e04aaa9e6c43293d34899be118b4b6d8286f584bab
|
File details
Details for the file botzone_cost-0.1.0-py3-none-any.whl.
File metadata
- Download URL: botzone_cost-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
29dd610d511cc28336640040385854b327d3927e005f2269d4ab94821de659b6
|
|
| MD5 |
820863819091f8521b9d9194cf42ed3d
|
|
| BLAKE2b-256 |
0a48cb8d9ea30be1dfc19b4a501d470a9a0d264aae488222f8d30f2ea7b0c59d
|