Skip to main content

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

# 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

MIT — see LICENSE and NOTICE.

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

bpmlinks_smartspend_test-0.1.2.tar.gz (383.3 kB view details)

Uploaded Source

Built Distribution

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

bpmlinks_smartspend_test-0.1.2-py3-none-any.whl (694.0 kB view details)

Uploaded Python 3

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page