Metadata-Version: 2.4
Name: spendline
Version: 0.1.0
Summary: Track LLM tokens, cost, latency, and model usage in production.
License: MIT
License-File: LICENSE
Keywords: llm,ai,openai,anthropic,bedrock,observability,cost-tracking
Author: Spendline
Author-email: hello@spendline.dev
Requires-Python: >=3.8
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
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: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Dist: httpx (>=0.24)
Requires-Dist: requests (>=2.28)
Project-URL: Documentation, https://github.com/emartai/spendline/tree/main/doc
Project-URL: Homepage, https://github.com/emartai/spendline
Project-URL: Issues, https://github.com/emartai/spendline/issues
Project-URL: Repository, https://github.com/emartai/spendline
Description-Content-Type: text/markdown

# Spendline Python SDK

Spendline tracks LLM usage in production with one line of code. The SDK captures tokens, model, latency, cost, timestamp, workflow ID, and request metadata without collecting prompt or completion text.

## Install

```bash
pip install spendline
```

## Quick Start

```python
from openai import OpenAI
from spendline import track

client = OpenAI()

response = track(
    client.chat.completions.create(
        model="gpt-5-mini",
        messages=[{"role": "user", "content": "Say hello"}],
    ),
    workflow_id="support-bot",
    session_id="session-123",
    metadata={"feature": "chat", "environment": "production"},
)

print(response.choices[0].message.content)
```

## Auto-Patch Supported Clients

```python
from spendline import patch

patch()
```

## LangChain

```python
from spendline.langchain import SpendlineCallbackHandler

handler = SpendlineCallbackHandler(workflow_id="chatbot")
```

## Supported Providers

| Provider | Support |
| --- | --- |
| OpenAI | `track()` and `patch()` |
| Anthropic | `track()` and `patch()` |
| Google Gemini | `track()` |
| DeepSeek | `track()` |
| Bedrock | `track()` |

## Environment Variables

| Variable | Purpose |
| --- | --- |
| `SPENDLINE_API_KEY` | Default ingest key |
| `SPENDLINE_API_URL` | Override API base URL |
| `SPENDLINE_DISABLE` | Disable tracking when `true` |
| `SPENDLINE_LOG` | Print tracked events locally |

## Privacy

Spendline does not collect:

- Prompt text
- Completion text
- Raw request bodies
- Secrets from your application context

