Stop paying for LLM calls you already know will fail: Budget Guard + circuit breakers in TypeScript
说明与用途
Resili 让 Node.js 开发者为异步函数(包括 LLM 调用)应用超时、重试和熔断策略,避免不必要的费用。
问题
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.
结果
Resili enables developers to avoid paying for failed LLM calls by applying circuit breakers and timeouts, reducing unnecessary retries and controlling costs.
工作流
- 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()
证据
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.
- 记录日期: 2026-10-22T14:11:23.957Z