Metadata-Version: 2.4
Name: weckr-sdk
Version: 0.1.0
Summary: AI cost and margin intelligence for SaaS founders
Project-URL: Homepage, https://useweckr.com
Project-URL: Documentation, https://useweckr.com/docs
Project-URL: Repository, https://github.com/Ghiles3232/weckr
Project-URL: Issues, https://github.com/Ghiles3232/weckr/issues
Author: Weckr
License: MIT License
        
        Copyright (c) 2026 Weckr
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: ai,anthropic,cost,finops,gemini,llm,monitoring,openai,saas
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
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: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: all
Requires-Dist: anthropic>=0.20.0; extra == 'all'
Requires-Dist: google-generativeai>=0.5.0; extra == 'all'
Requires-Dist: openai>=1.0.0; extra == 'all'
Provides-Extra: anthropic
Requires-Dist: anthropic>=0.20.0; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == 'dev'
Provides-Extra: gemini
Requires-Dist: google-generativeai>=0.5.0; extra == 'gemini'
Provides-Extra: openai
Requires-Dist: openai>=1.0.0; extra == 'openai'
Description-Content-Type: text/markdown

# weckr

Token-budget enforcement and observability for LLM apps. One line to wrap any OpenAI or Anthropic client.

## Install

```bash
pip install weckr
```

## Quick start

```python
import os
from openai import OpenAI
from weckr import Weckr

wk = Weckr(api_key=os.environ["WK_API_KEY"])
client = wk.wrap(OpenAI())

resp = client.chat.completions.create(
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
```

Every call is logged to your Weckr dashboard with token counts, latency, and cost. If you exceed your daily token cap, the next call raises `WeckrCapError` instead of silently burning money.

## How it works

`wk.wrap(client)` returns a proxy that:

1. Checks your remaining budget before each call (cached, ~5ms overhead).
2. Forwards the call to the underlying client unchanged.
3. Fires a non-blocking log to `api.weckr.dev` with usage data.

Works with sync and async clients. Streaming is passed through transparently — usage is logged when the stream closes.

## Anthropic

```python
from anthropic import Anthropic
from weckr import Weckr

wk = Weckr(api_key=os.environ["WK_API_KEY"])
client = wk.wrap(Anthropic())

msg = client.messages.create(
    model="claude-3-5-sonnet-latest",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello!"}],
)
```

## Direct chat

If you don't want to wrap a client, use `wk.chat` directly:

```python
text = wk.chat(
    provider="openai",
    model="gpt-4o-mini",
    messages=[{"role": "user", "content": "Hi"}],
)
```

`wk.chat` raises `WeckrCapError` if you're over budget.

## Configuration

| Env var          | Purpose                                        |
| ---------------- | ---------------------------------------------- |
| `WK_API_KEY`     | Your Weckr API key (starts with `wk_`)         |
| `OPENAI_API_KEY` | Forwarded to the OpenAI client                 |
| `ANTHROPIC_API_KEY` | Forwarded to the Anthropic client           |

Get your key at [weckr.dev](https://weckr.dev).

## License

MIT
