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.1.tar.gz (8.4 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.1-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: botzone_cost-0.1.1.tar.gz
  • Upload date:
  • Size: 8.4 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.1.tar.gz
Algorithm Hash digest
SHA256 d9b6c0e1839d27fa1c0f9cc555ff48bfbb45f201cd4df08676b8d44e135234b4
MD5 b4f3c73e466401baa610dc2e5241ace5
BLAKE2b-256 532ef5a510e6ddd31e6dcdb81c823c335782d95a191889ac94ee3eea8d3cde08

See more details on using hashes here.

Provenance

The following attestation bundles were made for botzone_cost-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: botzone_cost-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f570aa6b53d2ace75a3460e7f766e0eacaf43c86cf78def7740c45da721f2d0d
MD5 25e5adeec7fa7f00644d4f9d6b1a0ed7
BLAKE2b-256 e6e0a87328cfff6781911683b2983ada704e16fcc648d2dab3372ceabe111b27

See more details on using hashes here.

Provenance

The following attestation bundles were made for botzone_cost-0.1.1-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