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_onlyprivacy mode by default: token usage, model, latency, and attribution leave your process — prompt and completion content does not. Content capture is opt-in (redactedandfullmodes), not the default. - FinOps attribution is first-class. Tag every trace with
workload,task,team, andcost_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
# 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:
@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
The SmartSpend SDK is derived from open-source work distributed under the MIT license; original copyright notices are preserved in NOTICE. SmartSpend is an independent product and is not affiliated with or endorsed by the authors of that work.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bpmlinks_smartspend_test-0.1.0.tar.gz.
File metadata
- Download URL: bpmlinks_smartspend_test-0.1.0.tar.gz
- Upload date:
- Size: 382.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb3c9a8072fe71d04ad1b50829140b3bd367587e5f10c66d30570a235e7a743e
|
|
| MD5 |
b0ba1eb2f0ad4adb00ff026131882a46
|
|
| BLAKE2b-256 |
614cd6771a6e8dab540660abfab00802691c11c15a04a7a6f180d6ae68af3dcc
|
File details
Details for the file bpmlinks_smartspend_test-0.1.0-py3-none-any.whl.
File metadata
- Download URL: bpmlinks_smartspend_test-0.1.0-py3-none-any.whl
- Upload date:
- Size: 694.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca3ceb683ba27c13e4722b375f5f44aae408c9aab9938a3afd1a5bb8bb75c9dd
|
|
| MD5 |
2f7ddc29b05353d8c1e4d9498b39820c
|
|
| BLAKE2b-256 |
7e01c82f77b96a546a3fff4026b5a776902c28d33027e5120e5763ac444017f7
|