Skip to content

v0.8.0 — Cost-Aware Execution

Choose a tag to compare

@lacrous lacrous released this 23 Aug 08:01
· 8 commits to main since this release

v0.8.0 — Cost-Aware Execution

💰 The Problem

AI costs are unpredictable. Developers set a model and pray. OpenAI SDK and Vercel AI SDK don't provide budget enforcement or cost tracking.

🎯 The Solution

Hilbras SDK now provides automatic cost tracking with budget enforcement:

const client = new HilbrasClient({
  budget: {
    sessionBudget: 1.00,       // Max total cost for the session
    perRequestBudget: 0.10,    // Max cost per individual request
    onBudgetWarning: (report) => console.warn(`80% budget used`),
    onBudgetExceeded: (report) => console.error(`Budget exhausted`),
  },
});

// After requests — full cost visibility
const report = client.costReport();
console.log(`Total spent: $${report.totalActual}`);
console.log(`By provider:`, report.byProvider);

What's Included

  • BudgetTracker — session and per-request budget enforcement
  • Cost lifecycle — estimate → execute → actual tracking
  • Budget callbacks — warning at 80%, exceeded at 100%
  • Cost reporting — by provider, by phase, remaining budget
  • Zero overhead — no cost when budget not configured
  • Backward compatible — existing code works unchanged

How It Differentiates

Capability OpenAI SDK Vercel AI SDK Hilbras SDK
Provider abstraction OpenAI only Multi-provider Multi-provider
Model routing None Basic 9-dimension scoring
Structured output Limited Limited Schema + auto-repair
Fallback None None Automatic, policy-driven
Budget enforcement None None Session + per-request
Cost tracking None None Full lifecycle
Cost reporting None None By provider, by phase
Execution policies None None 5 presets + custom
Observability Limited Limited 9 lifecycle events

566 Tests Passing

29 new tests covering BudgetTracker, cost enforcement, client integration, concurrency, and adversarial inputs.


Changelog: https://github.com/Hilbras/Hilbras-ai-sdk/blob/main/CHANGELOG.md