Metadata-Version: 2.4
Name: tare-sdk
Version: 0.1.0
Summary: LLM cost attribution proxy SDK — drop-in OpenAI client with feature tagging
Project-URL: Homepage, https://github.com/your-org/tare
Project-URL: Repository, https://github.com/your-org/tare
Project-URL: Bug Tracker, https://github.com/your-org/tare/issues
Author: Tare
License: MIT
Keywords: analytics,attribution,cost,llm,observability,openai,proxy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: anthropic>=0.18.0
Requires-Dist: httpx>=0.27.0
Requires-Dist: openai>=1.0.0
Provides-Extra: dev
Requires-Dist: httpx>=0.27.0; extra == 'dev'
Requires-Dist: pytest-asyncio; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# 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

```python
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

```bash
# 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.

```python
# 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

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

> **Reminder:** Add a LICENSE file before publishing to PyPI.
