Skip to main content

Cost-tracking SDK for Anthropic, OpenAI, and Gemini Python clients

Project description

botzone-cost

PyPI version Python versions license

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


Download files

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

Source Distribution

botzone_cost-0.1.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

botzone_cost-0.1.2-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file botzone_cost-0.1.2.tar.gz.

File metadata

  • Download URL: botzone_cost-0.1.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for botzone_cost-0.1.2.tar.gz
Algorithm Hash digest
SHA256 158205f4163f9ee9030c586c8293be078fdc1dcb35414becedd99ee8f995b800
MD5 ff831462743c16650dc9756e42a9377a
BLAKE2b-256 a44395084b29bcc331df90705c94b24151439e7198a84cb82985c86a820d2254

See more details on using hashes here.

Provenance

The following attestation bundles were made for botzone_cost-0.1.2.tar.gz:

Publisher: publish.yml on botzone-ai/cost-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file botzone_cost-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: botzone_cost-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 8.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for botzone_cost-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e4482e57489909fb8c6763c40133002734716b732331f9a56a4910bbd5f817c9
MD5 bcf68140176ca67233a78af2480c2aac
BLAKE2b-256 02bb93687bd590ac4051ec8a6b187f34c740165a0ab8374bd7f4d915e36c7841

See more details on using hashes here.

Provenance

The following attestation bundles were made for botzone_cost-0.1.2-py3-none-any.whl:

Publisher: publish.yml on botzone-ai/cost-sdk-py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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