AI cost and margin intelligence for SaaS founders
Project description
weckr
Token-budget enforcement and observability for LLM apps. One line to wrap any OpenAI or Anthropic client.
Install
pip install weckr
Quick start
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:
- Checks your remaining budget before each call (cached, ~5ms overhead).
- Forwards the call to the underlying client unchanged.
- Fires a non-blocking log to
api.weckr.devwith usage data.
Works with sync and async clients. Streaming is passed through transparently — usage is logged when the stream closes.
Anthropic
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:
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.
License
MIT
Project details
Release history Release notifications | RSS feed
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 weckr_sdk-0.1.0.tar.gz.
File metadata
- Download URL: weckr_sdk-0.1.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f18d6d1a5f8b76d224cb92c1882680356b24bfcd552e08d93185bbf7d543be7c
|
|
| MD5 |
70baee3de1d5b0df0ff09706334431d5
|
|
| BLAKE2b-256 |
46d041e18b76af411ea1f6fb8679caec8d3863ffcfe13aba98e79dcf459e972c
|
File details
Details for the file weckr_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: weckr_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5090e59c61169da22fdd535950804e876027a3b54128a5ca7a1e6c59c1664b45
|
|
| MD5 |
1f65da63521ca35c731d0639d71acaba
|
|
| BLAKE2b-256 |
d2e718c75eb83c13f3354930708cc07a018d3be7dc484867b054c91c1791ef08
|