Aurex Python SDK (aurex-sdk)
Open-source, in-process LLM cost shield, runtime circuit breaker, and CI regression gate for Python—with zero proxy latency and zero raw prompts leaving your servers.
1. What Problems Are People Facing?
- Silent cache & cliff traps: Putting a changing timestamp or unsorted JSON schema in a system prompt wipes out 50%–90% prompt-cache discounts, and crossing
200,000input tokens doubles the price of the entire request on Claude 4+ and Gemini 2.5+. - Unbounded runtime spend: Looping agents, hidden reasoning tokens, aborted streams, and multiplied SDK retries can drain budgets in seconds without a per-session kill switch.
- Paid soft failures: Models return HTTP
200 OKwith empty text or repeated JSON/newline loops that still bill at full output rates while producing nothing usable.
2. What Does Aurex Solve?
aurex-sdk drops into your existing OpenAI, Anthropic, Google Gemini, Groq, Together, LiteLLM, Hugging Face, and Ollama calls with zero rewrites—protecting every request across three stages:
- Before the call: Keeps prompt caches warm by sorting JSON keys deterministically, pinpoints the exact character offset breaking your cache, flags
>5 minidle cache-expiry gaps, and warns before the200k2x price jump. - During the call: Enforces per-session and per-minute dollar caps (shared across workers via optional Redis), caps hidden thinking tokens, tracks aborted streams, stops duplicate retries, and raises
AurexBlockedon loops. - After the call + CI: Flags paid empty or looped HTTP-200 responses as wasted spend, pairs spend with
mark_success()to measure true cost per completed task, and posts cost regression diffs on Pull Requests.
3. How to Use It (Step-by-Step)
Step 1: Install
pip install aurex-sdk
# Optional multi-worker Redis & OpenTelemetry support:
pip install "aurex-sdk[redis,otel]"
Step 2: Initialize Once at App Startup
from aurex_sdk import AurexAuditor, AurexBlocked, AurexConfig, patch_all
import openai
auditor = AurexAuditor(
AurexConfig(
budget_guard={
"max_cost_per_session": 1.50,
"max_thinking_tokens": 4096,
"on_budget_exceeded": "throw",
},
enable_loop_guard=True,
)
)
patch_all(auditor)
client = openai.OpenAI()
try:
resp = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Draft release notes."}],
workflow_id="release-job-1",
)
auditor.mark_success("release-job-1")
except AurexBlocked as err:
print(f"Stopped runaway session {err.workflow_id}: {err.reason}")
finally:
auditor.flush()
Step 3: Run Local Audit & CI PR Gate
aurex audit
aurex ci --ledger .aurex/ledger.jsonl --baseline main_ledger.jsonl --github-comment --fail-on-regression
(Zero-code option: run aurex install-hook once, then start your app with AUREX_ENABLED=1.)
4. How Can You Improve Your Setup?
- Keep your system prompt static: Move changing dates, request IDs, or user context to the end of the user message so 50%–90% cache discounts stay active.
- Avoid the
200k2x cliff: Set"max_context_tokens": 195000inbudget_guardon long Claude 4+ and Gemini 2.5+ threads. - Enable Redis across workers: Set
AUREX_REDIS_URL=redis://localhost:6379/0so Gunicorn, Uvicorn, or Celery workers enforce one shared budget. - Full docs & AI-agent guide: Visit https://github.com/bhav09/aurex-sdk (includes
llms.txtandAGENTS.mdfor coding assistants).
Metadata
Release files for aurex-sdk 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aurex_sdk-0.5.1.tar.gz | 85.9 kB | Without provenance | Details for aurex_sdk-0.5.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aurex_sdk-0.5.1-py3-none-any.whl | Python 3 | none | any | Details for aurex_sdk-0.5.1-py3-none-any.whl |
Total release size: 159.9 kB
Release files / aurex_sdk-0.5.1.tar.gz
| Download URL | aurex_sdk-0.5.1.tar.gz |
|---|---|
| Size | 85.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
846f40805453e4a515991724371dc1a547f9bf7d8208af7b525911abadba1278
|
|
BLAKE2b-256 checksum How to use checksums |
9871605ac415c11ce9e8da7dd73b105bbdb50bfa8006e71662cae1803e11b92b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / aurex_sdk-0.5.1-py3-none-any.whl
| Download URL | aurex_sdk-0.5.1-py3-none-any.whl |
|---|---|
| Size | 74.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3df4096343e2f5cbfa32055274c6ad169224a353abed303a30010a3cb6b1c6bc
|
|
BLAKE2b-256 checksum How to use checksums |
7dcca93dd0b04c3148ed1e2b315a8162f7c05e7881a9801d37c570fbfadad288
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for aurex-sdk 0.5.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.