The control layer for autonomous AI spend — track, budget, and hard-stop your AI API usage.
Project description
CostWindow
The control layer for autonomous AI spend. Track every call, set hard budgets, and kill any process instantly — for CostWindow.
The fastest way: the drop-in proxy (no SDK, any language)
Change one line — your AI client's base URL — and every call is tracked, with a hard kill switch in front of it. Killed or over-budget processes are refused before the provider is called. Your provider API key passes straight through and is never stored.
# Anthropic (Python)
client = anthropic.Anthropic(
base_url="https://api.costwindow.com/proxy/anthropic/cw_live_your_key",
)
# OpenAI (Python) — note the /v1
client = openai.OpenAI(
base_url="https://api.costwindow.com/proxy/openai/cw_live_your_key/v1",
)
// Anthropic (JS/TS) — works for any language, just set the base URL
const client = new Anthropic({
baseURL: "https://api.costwindow.com/proxy/anthropic/cw_live_your_key",
});
// OpenAI (JS/TS) — note the /v1
const client = new OpenAI({
baseURL: "https://api.costwindow.com/proxy/openai/cw_live_your_key/v1",
});
# Or straight cURL — same idea in any stack
curl https://api.costwindow.com/proxy/anthropic/cw_live_your_key/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" -H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" -d '{ "model": "claude-sonnet-4-6", ... }'
Optionally add a header X-CostWindow-Label: my-process to name the process
(otherwise it's proxy-anthropic / proxy-openai / proxy-google).
Get your cw_live_ key from Settings in your dashboard.
The Python SDK (when you can't change the base URL)
For scripts where the proxy isn't practical, this SDK reports usage after each call.
pip install git+https://github.com/aicraft0000-blip/costwindow-sdk.git
from costwindow import CostWindow
import anthropic
cw = CostWindow(api_key="cw_live_...") # backend defaults to api.costwindow.com
client = cw.wrap_anthropic(anthropic.Anthropic())
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1000,
messages=[{"role": "user", "content": "Hello"}],
cw_label="my-script",
)
cw.wrap_openai() and cw.wrap_gemini() work the same way.
Kill switch for cron jobs
from costwindow import CostWindow, CostWindowProcessDisabledError
cw = CostWindow(api_key="cw_live_...")
if not cw.is_active("my-cron"):
raise SystemExit("Process killed in CostWindow — skipping run.")
CostWindow never breaks your script: if the service is unreachable, errors are
logged to ~/.costwindow/logs/ and swallowed. The only exception that
propagates is CostWindowProcessDisabledError — raised when a wrapped call hits
a process you've kill-switched in the dashboard.
MIT licensed. Questions → costwindow.com.
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 costwindow-0.2.0.tar.gz.
File metadata
- Download URL: costwindow-0.2.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d145d77f1be8fef2ed4daceddc9155a9b0cb7f0a82e04dbd459f0d0eef88e3c
|
|
| MD5 |
5a20293ba1ec268bf65d9c9b3e2e2e90
|
|
| BLAKE2b-256 |
e4727260e1e2304c4910088998e710c38d47551f73c6c7d7ffadc836a99b47bc
|
File details
Details for the file costwindow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: costwindow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20cc3ba7eb3ac96e50f4e0d353c771824ddef2d61db69c5b05c7d1e8e628e9a4
|
|
| MD5 |
c6a42bf23348217767a31a4becdca99d
|
|
| BLAKE2b-256 |
21de62559dd33a46c3a5cc1912da00e14a09c3dd4d1cc8865249500be56e101f
|