Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

costwindow-0.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

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

costwindow-0.2.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

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

Hashes for costwindow-0.2.0.tar.gz
Algorithm Hash digest
SHA256 5d145d77f1be8fef2ed4daceddc9155a9b0cb7f0a82e04dbd459f0d0eef88e3c
MD5 5a20293ba1ec268bf65d9c9b3e2e2e90
BLAKE2b-256 e4727260e1e2304c4910088998e710c38d47551f73c6c7d7ffadc836a99b47bc

See more details on using hashes here.

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

Hashes for costwindow-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 20cc3ba7eb3ac96e50f4e0d353c771824ddef2d61db69c5b05c7d1e8e628e9a4
MD5 c6a42bf23348217767a31a4becdca99d
BLAKE2b-256 21de62559dd33a46c3a5cc1912da00e14a09c3dd4d1cc8865249500be56e101f

See more details on using hashes here.

Supported by

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