Metadata-Version: 2.5
Name: bpmlinks_smartspend_test
Version: 0.1.1
Summary: SmartSpend Python SDK - LLM observability/tracing, datasets, experiments, LLM-as-a-judge evaluation, and prompt management
Author-email: BPMLinks <Naresh.Edagotti@bpmlinks.com>
License-Expression: MIT
License-File: LICENSE
License-File: NOTICE
Requires-Python: <4.0,>=3.10
Requires-Dist: backoff>=1.10.0
Requires-Dist: httpx<1.0,>=0.15.4
Requires-Dist: opentelemetry-api<2,>=1.33.1
Requires-Dist: opentelemetry-exporter-otlp-proto-http<2,>=1.33.1
Requires-Dist: opentelemetry-sdk<2,>=1.33.1
Requires-Dist: packaging<27.0,>=23.2
Requires-Dist: pydantic<3,>=2
Requires-Dist: wrapt<3,>=1.14
Description-Content-Type: text/markdown

# SmartSpend Python SDK

**SmartSpend is an AI FinOps platform: observability and cost intelligence in one.**

One SDK captures everything your AI workloads do — models, tokens, latency, errors,
retries, business attribution — and the SmartSpend platform turns that into cost
analytics, optimization recommendations, and verified savings. No separate
observability tool, no separate FinOps tool.

## Why SmartSpend

- **Cost needs metadata, not your prompts.** SmartSpend runs in `metadata_only`
  privacy mode by default: token usage, model, latency, and attribution leave your
  process — prompt and completion content does not. Content capture is opt-in
  (`redacted` and `full` modes), not the default.
- **FinOps attribution is first-class.** Tag every trace with `workload`, `task`,
  `team`, and `cost_center` — at the client, or per request — and slice spend by
  those dimensions in the platform.
- **Provider-aware.** Automatic instrumentation for OpenAI (incl. Azure OpenAI) and
  Anthropic, with cached-token and reasoning-token usage normalized so prompt
  caching is priced correctly, plus OpenTelemetry `gen_ai.*` interop for
  everything else (LangChain handler included).
- **Standard OpenTelemetry underneath.** Spans export via OTLP; bring your own
  tracer provider, span filters, or export-stage masking if you need more control.

## Installation

```
pip install smartspend
```

## Quickstart

```python
# env: SMARTSPEND_PUBLIC_KEY, SMARTSPEND_SECRET_KEY, SMARTSPEND_BASE_URL

from smartspend import SmartSpend, observe, propagate_attributes

ss = SmartSpend(
    workload="support-bot",        # FinOps defaults applied to every trace
    team="platform",
    cost_center="cc-1001",
    # privacy_mode="metadata_only" is the default: content never leaves your process
)

# Automatic LLM instrumentation — drop-in imports
from smartspend.openai import openai          # instead of `import openai`
from smartspend.anthropic import anthropic    # instead of `import anthropic`

with propagate_attributes(user_id="user-123", task="summarize-ticket"):
    completion = openai.OpenAI().chat.completions.create(
        model="gpt-4o-mini",
        messages=[{"role": "user", "content": "Summarize this ticket..."}],
    )
# → captured with model, token usage (incl. cached tokens), latency, cost
#   attribution by workload/task/team/cost_center — content stripped by default.
```

Or instrument any function with the decorator:

```python
@observe()
def handle_request(query: str) -> str:
    ...
```

## Privacy modes

| Mode | What leaves your process |
|---|---|
| `metadata_only` (default) | Usage, model, latency, errors, attribution metadata — **no prompt/completion content** |
| `redacted` | Same, plus content attributes replaced with `"<redacted>"` |
| `full` | Everything (explicit opt-in) |

Set via `SmartSpend(privacy_mode=...)` or `SMARTSPEND_PRIVACY_MODE`.

## License & acknowledgements

MIT — see [LICENSE](LICENSE) and [NOTICE](NOTICE).

The SmartSpend SDK is derived from open-source work distributed under the MIT
license; original copyright notices are preserved in [NOTICE](NOTICE). SmartSpend
is an independent product and is not affiliated with or endorsed by the authors
of that work.
