Stop paying for LLM calls you already know will fail: Budget Guard + circuit breakers in TypeScript
Description and use
Resili lets Node.js developers apply timeout, retry, and circuit‑breaker policies to async functions, including LLM calls, to avoid unnecessary costs.
Problem
Node.js applications often use ad‑hoc retry, timeout, and circuit‑breaker logic that is error‑prone, hard to maintain, and can cause unnecessary LLM calls that waste money.
Outcome
Resili enables developers to avoid paying for failed LLM calls by applying circuit breakers and timeouts, reducing unnecessary retries and controlling costs.
Workflow
- 1. Import resili from @resili/core.
- 2. Wrap an async function (e.g., fetch) with resili().
- 3. Chain desired policies: timeout(), retry(), circuitBreaker(), etc.
- 4. Call build() to create the resilient wrapper.
- 5. Invoke the wrapper via .call() with arguments.
- 6. For LLMs, create a provider adapter (e.g., createOpenAiProvider) and pass it to createLlmClient, then use .generate()
Evidence
Resili is a TypeScript‑first resilience toolkit for Node.js. It wraps an async function (not a URL, not a request object) in typed policies, and it has separate packages for fetch/axios/undici and for OpenAI, Anthropic and Gemini.
Invalid options throw when the client is built, not at 3 a.m. on the first failure.
The second call fails fast with ERR_CIRCUIT_OPEN without touching the dependency.
- Record date: 2026-10-22T14:11:23.957Z