Introducing Ayeixa FuelLite: Free-Tier Token Arbitrage & Dynamic Failover Router
Continuous autonomous agent execution loops consume substantial token volumes. In multi-tenant environments, unmonitored model calls quickly trigger rate limits (HTTP 429) or excessive API billing.
Ayeixa FuelLite (@ayeixa/fuellite) is an open-source TypeScript library for zero-cost multi-provider token arbitrage, quota tracking, and resilient failover.
- GitHub Repository: https://github.com/alpallovy/ayeixa-fuellite
-
Status: Pre-Release (
v0.1.0-alpha) - License: MIT
- NPM Status: Public registry publication is pending; evaluate and build locally.
1. Core Architecture
FuelLite provides four synchronized modules:
- CostEstimator: Deterministic numeric cost estimation using token counts and configured provider rates, with reported USD values rounded to six decimal places.
-
ProviderArbitrageRouter: Ranks configured model providers, prioritizing providers configured as free-tier (
isFreeTier: true) before falling back to lower-cost paid endpoints. - TokenBudgetTracker: Tracks cumulative tenant and session token budgets with hard-stop limits and threshold warning alarms.
- FailoverExecutor: Transparently handles provider outages and rate limits with exponential backoff ($2^n \times \text{base}$) and cooldown recovery.
2. Implemented Capabilities & Test Verification
Verified with hermetic unit tests:
-
Cost Estimation: Six-decimal USD calculation across token counts (
tests/cost.test.ts). -
Arbitrage Routing: Prioritizing configured free-tier providers and lowest cost (
tests/arbitrage.test.ts). -
Budget Tracking: Hard quota enforcement and spend recording (
tests/budget.test.ts). -
Failover Logic: HTTP 429/503 retry backoff and provider hopping (
tests/failover.test.ts).
Verification: 6/6 hermetic unit tests passing (0 failures).
3. Local Quick Start
git clone https://github.com/alpallovy/ayeixa-fuellite.git
cd ayeixa-fuellite
npm ci
npm run build
npm test
Usage Example
import { CostEstimator, ProviderArbitrageRouter, TokenBudgetTracker } from './src';
const estimator = new CostEstimator();
const cost = estimator.calculateCost({
provider: 'gemini-flash',
inputTokens: 1500,
outputTokens: 400,
isFreeTier: true
});
console.log("Total Cost (USD):", cost.totalCostUsd); // 0.0
const tracker = new TokenBudgetTracker({ maxBudgetUsd: 5.0 });
tracker.recordSpend("tenant-alpha", cost.totalCostUsd, 1900);
console.log("Remaining Budget:", tracker.getRemainingBudget("tenant-alpha"));
4. Limitations & Contributing
- Pre-release
v0.1.0-alpha. Provider rates are statically configured. - Public npm publication is pending.
- Feedback and PRs welcome! See open
good first issueitems on GitHub.
License: MIT
Top comments (0)