Skip to main content

LLM cost attribution proxy SDK — drop-in OpenAI client with feature tagging

Project description

Tare SDK

Drop-in replacement for openai.OpenAI that routes every call through the Tare proxy and attributes cost to the product feature that made it.

5-line integration

import tare

llm = tare.client(api_key="sk-...", feature="chat")
resp = llm.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Summarise this in one sentence."}],
)
print(resp.choices[0].message.content)

That's it — every call is now tracked in the Tare dashboard, broken down by the feature label you pass.

Installation

# From the monorepo root (local dev)
pip install -e ./sdk

# Future PyPI release
pip install tare

Configuration

Env var Default Description
TARE_PROXY_URL http://localhost:8000 Running Tare proxy base URL

The /v1 path suffix is appended automatically, so you never need to add it.

# Override at call time — useful in staging / prod
llm = tare.client(
    api_key="sk-...",
    feature="summarizer",
    proxy_url="https://tare.internal",
)

How it works

tare.client() returns a standard openai.OpenAI instance configured with:

  • base_url<proxy_url>/v1
  • default_headers{"X-Tare-Feature": "<feature>"}

The proxy forwards the request to OpenAI unchanged, records token usage, cost, and latency against the feature label, then returns the original response. Zero behaviour change for the caller.

Running the test suite

# Requires the proxy running on localhost:8000
cd sdk
pip install -e ".[dev]"
pytest

Reminder: Add a LICENSE file before publishing to PyPI.

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

tare_sdk-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

tare_sdk-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file tare_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: tare_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for tare_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b403674ff1e306ab3a9b3d03a0df5168430c06fc8c4c7f7c3f2891e1a67f9b93
MD5 05185e39ed523f40dfb5e32d14e0e825
BLAKE2b-256 5173506988c5f65fe59478b607980ac2ec52d342e9bee4236e75c76f38a0dcfc

See more details on using hashes here.

File details

Details for the file tare_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: tare_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for tare_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d70b2884e929915b77f2ae095265adb6b24e7b46bc6630fb2e7b7ded7d864fa1
MD5 9dbb6efe4ea1b95d0779000c44060c2a
BLAKE2b-256 34ba01b2fde0a8a3381075ce95a623f562ea9ca3633d39720ae7a3bf310ce7c9

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